From 41956e5d37adef630b454fc220448bc4afaaf42a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:27:39 +0000 Subject: [PATCH 01/47] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65e9a02..3dd0016 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-slice-assign": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/slice-multi": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 90e5be5ffe62591ef3a017cb787ab47431820013 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:29:57 +0000 Subject: [PATCH 02/47] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 87 +- benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 176 - package.json | 83 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 --------- 42 files changed, 6225 insertions(+), 8814 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index a8be1e6..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -344,7 +337,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -404,19 +397,19 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib +[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index bca98fb..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 03c6700..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 79a0fb0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d1df197..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var d=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var h=d(function(V,g){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),w=require("@stdlib/assert-is-multi-slice"),f=require("@stdlib/assert-is-array-like-object"),p=require("@stdlib/assert-is-plain-object"),y=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),b=require("@stdlib/assert-has-own-property"),c=require("@stdlib/slice-multi"),S=require("@stdlib/ndarray-base-slice-assign"),E=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function T(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(p(arguments[i-1])){if(i-=1,n=arguments[i],b(n,"strict")){if(!y(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=E(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(w(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(f(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = MultiSlice.apply( null, args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAAChB,EAAeY,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACZ,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKR,EAAYQ,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKV,EAAe,UAAWa,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBV,EAAYS,EAAS,QAAS,EAAI,CACtC,GAAK,CAACX,EAAWW,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKlB,EAAca,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKd,EAAmBY,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAW,MAAO,KAAMW,CAAK,CAClC,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAId,EAAYW,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAlB,EAAO,QAAUY,ICtGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 72bc4e2..c6be4ef 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1ddddb4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function h(h,p,c){var j,v,f,g,u,b,y;if(f={strict:!0},v=arguments.length,!t(h))throw new TypeError(l("invalid argument. First argument must be an ndarray. Value: `%s`.",h));if(!t(p))throw new TypeError(l("invalid argument. Second argument must be an ndarray. Value: `%s`.",p));if(n(p))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[v-1])){if(o(j=arguments[v-=1],"strict")){if(!i(j.strict))throw new TypeError(l("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",j.strict));f.strict=j.strict}if(u=d(p),2===v&&u.length>0)throw new RangeError(l("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",u.join(","),0))}if(r(c)){if(b=c,v>3)throw new Error("invalid invocation. Too many arguments.")}else{if(s(c)){if(g=c,v>3)throw new Error("invalid invocation. Too many arguments.")}else for(g=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = MultiSlice.apply( null, args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","MultiSlice","apply","err","String","base"],"mappings":";;miCAuGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAWC,MAAO,KAAMtB,EAU5B,CATC,MAAQuB,GAET,IAAMpB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIkB,EAAYrB,EAAMG,GAGtB,CAFC,MAAQoB,GACT,MAAM,IAAIf,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 83678cf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,176 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = MultiSlice.apply( null, args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 3dd0016..5569e29 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,62 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-array-like-object": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-multi-slice": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.1.1", - "@stdlib/ndarray-base-slice-assign": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/slice-multi": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-typed": "^0.1.0", - "@stdlib/array-zeros": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.1.0", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-empty": "^0.1.0", - "@stdlib/ndarray-base-from-scalar": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-empty": "^0.1.0", - "@stdlib/ndarray-from-scalar": "^0.1.0", - "@stdlib/ndarray-slice": "github:stdlib-js/ndarray-slice#main", - "@stdlib/ndarray-to-array": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "@stdlib/slice-ctor": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a277368 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 0c8c2ecfd7d512542e9b77d870b763cbcdaa8913 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:30:45 +0000 Subject: [PATCH 03/47] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 08a6144..dc361b0 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.1.0-esm/index.mjs'; ``` #### sliceAssign( x, y, ...s\[, options] ) @@ -240,7 +240,7 @@ import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-s import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import ndzeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; import slice from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice@esm/index.mjs'; -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.1.0-esm/index.mjs'; // Alias `null` to allow for more compact indexing expressions: var _ = null; From ec33122ddac693ba837faf4d537077f3df10b876 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:30:46 +0000 Subject: [PATCH 04/47] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dc361b0..6b6fe25 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-slice-assign/tags). For example, + ```javascript import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.1.0-esm/index.mjs'; ``` @@ -240,7 +245,7 @@ import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-s import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import ndzeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; import slice from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice@esm/index.mjs'; -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.1.0-esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; // Alias `null` to allow for more compact indexing expressions: var _ = null; From e74be32b158b4271f9752266dd87255919adaebd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 20:38:32 +0000 Subject: [PATCH 05/47] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b604400..b4096a4 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/slice-base-args2multislice": "github:stdlib-js/slice-base-args2multislice#main", "@stdlib/slice-multi": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 169ece37ff60b82994b6dd5d4a646a04f650e02e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 20:39:25 +0000 Subject: [PATCH 06/47] Remove files --- index.d.ts | 2385 ------------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 8567 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 c6be4ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2385 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* tslint:disable:max-file-line-count */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1ddddb4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function h(h,p,c){var j,v,f,g,u,b,y;if(f={strict:!0},v=arguments.length,!t(h))throw new TypeError(l("invalid argument. First argument must be an ndarray. Value: `%s`.",h));if(!t(p))throw new TypeError(l("invalid argument. Second argument must be an ndarray. Value: `%s`.",p));if(n(p))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[v-1])){if(o(j=arguments[v-=1],"strict")){if(!i(j.strict))throw new TypeError(l("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",j.strict));f.strict=j.strict}if(u=d(p),2===v&&u.length>0)throw new RangeError(l("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",u.join(","),0))}if(r(c)){if(b=c,v>3)throw new Error("invalid invocation. Too many arguments.")}else{if(s(c)){if(g=c,v>3)throw new Error("invalid invocation. Too many arguments.")}else for(g=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = MultiSlice.apply( null, args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","MultiSlice","apply","err","String","base"],"mappings":";;miCAuGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAWC,MAAO,KAAMtB,EAU5B,CATC,MAAQuB,GAET,IAAMpB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIkB,EAAYrB,EAAMG,GAGtB,CAFC,MAAQoB,GACT,MAAM,IAAIf,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a277368..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 24572d217b2122825f4ec8751079e91a102aa771 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 20:41:07 +0000 Subject: [PATCH 07/47] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 87 +- benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 84 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 --------- 42 files changed, 6225 insertions(+), 8816 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index a8be1e6..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -344,7 +337,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -404,19 +397,19 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib +[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index bca98fb..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 03c6700..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 79a0fb0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 72bc4e2..c6be4ef 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1835a34 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;woCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 c35fd62..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index b4096a4..5569e29 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-array-like-object": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-multi-slice": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.1.1", - "@stdlib/ndarray-base-slice-assign": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/slice-base-args2multislice": "github:stdlib-js/slice-base-args2multislice#main", - "@stdlib/slice-multi": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-typed": "^0.1.0", - "@stdlib/array-zeros": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.1.0", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-empty": "^0.1.0", - "@stdlib/ndarray-base-from-scalar": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-empty": "^0.1.0", - "@stdlib/ndarray-from-scalar": "^0.1.0", - "@stdlib/ndarray-slice": "^0.1.0", - "@stdlib/ndarray-to-array": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "@stdlib/slice-ctor": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f84a4d4 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From cb9239368094a5e18b888c1c4dc1b7c2dbaf5e86 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Oct 2023 22:27:46 +0000 Subject: [PATCH 08/47] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de89667..3e736b6 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/slice-base-args2multislice": "^0.1.0", "@stdlib/slice-multi": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From b7588e594524cd7ae9aaaa27dd6548b8cca705a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Oct 2023 22:33:21 +0000 Subject: [PATCH 09/47] Remove files --- index.d.ts | 2385 ------------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 8567 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 c6be4ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2385 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* tslint:disable:max-file-line-count */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1835a34..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;woCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f84a4d4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 642dc6f526f0c893ace94c9176826ece0da97a29 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Oct 2023 22:34:53 +0000 Subject: [PATCH 10/47] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 87 +- benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 84 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 --------- 42 files changed, 6225 insertions(+), 8816 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index a8be1e6..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -344,7 +337,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -404,19 +397,19 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib +[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index bca98fb..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 03c6700..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 79a0fb0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 69cac97..2e96b9c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e486699 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;+oCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 c35fd62..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 3e736b6..5569e29 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-array-like-object": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-multi-slice": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.1.1", - "@stdlib/ndarray-base-slice-assign": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/slice-base-args2multislice": "^0.1.0", - "@stdlib/slice-multi": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-typed": "^0.1.0", - "@stdlib/array-zeros": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.1.0", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-empty": "^0.1.0", - "@stdlib/ndarray-base-from-scalar": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-empty": "^0.1.0", - "@stdlib/ndarray-from-scalar": "^0.1.0", - "@stdlib/ndarray-slice": "^0.1.0", - "@stdlib/ndarray-to-array": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "@stdlib/slice-ctor": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4d9a002 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 85bf72175f760b13214ae0687751c23fed92c279 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:34:58 +0000 Subject: [PATCH 11/47] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3699d9a..b67d950 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/slice-base-args2multislice": "^0.1.0", "@stdlib/slice-multi": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From fd98e5624b77b8575744ae37595f059898e232e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:14:29 +0000 Subject: [PATCH 12/47] Remove files --- index.d.ts | 2379 ------------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 8561 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 2e96b9c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* tslint:disable:max-file-line-count */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // tslint:disable-line:unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e486699..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;+oCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4d9a002..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d9af50534600a40ab4d1ac7d1a5d862296cbccf2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:15:06 +0000 Subject: [PATCH 13/47] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 91 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 84 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 --------- 44 files changed, 6227 insertions(+), 8820 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 02db98e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:32:30.818Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa52835..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -352,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -412,25 +405,25 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 79a0fb0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 9ee4004..842203a 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..393af94 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;+oCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 c35fd62..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index b67d950..5569e29 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-array-like-object": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-multi-slice": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.1.1", - "@stdlib/ndarray-base-slice-assign": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/slice-base-args2multislice": "^0.1.0", - "@stdlib/slice-multi": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-typed": "^0.1.0", - "@stdlib/array-zeros": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.1.0", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-empty": "^0.1.1", - "@stdlib/ndarray-base-from-scalar": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-empty": "^0.1.0", - "@stdlib/ndarray-from-scalar": "^0.1.0", - "@stdlib/ndarray-slice": "^0.1.0", - "@stdlib/ndarray-to-array": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "@stdlib/slice-ctor": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c264292 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 2b2e5c69ec6d59f85cd3f31fb6d82b0c2aea5b2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 02:37:56 +0000 Subject: [PATCH 14/47] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aa67f11..f2b7bfc 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.0", "@stdlib/slice-base-args2multislice": "^0.2.0", "@stdlib/slice-multi": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From 4876ae5c4f3d8e33cfe62ce61282a562768fc6d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:23:56 +0000 Subject: [PATCH 15/47] Remove files --- index.d.ts | 2379 ------------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 8561 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 842203a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var typedarray = require( `@stdlib/array/typed` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( `@stdlib/slice/ctor` ); -* var MultiSlice = require( `@stdlib/slice/multi` ); -* var ndarray = require( `@stdlib/ndarray/ctor` ); -* var ndzeros = require( `@stdlib/ndarray/zeros` ); -* var ndarray2array = require( `@stdlib/ndarray/to-array` ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 393af94..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;+oCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c264292..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 31aa41c91e267663879b67c928ac48d4f36886c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:25:22 +0000 Subject: [PATCH 16/47] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 84 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 --------- 43 files changed, 6227 insertions(+), 8828 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) 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 04e1ae4..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..de67e35 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;+oCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 c35fd62..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index f2b7bfc..ae258ee 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.0", - "@stdlib/assert-is-array-like-object": "^0.2.0", - "@stdlib/assert-is-boolean": "^0.2.0", - "@stdlib/assert-is-multi-slice": "^0.2.0", - "@stdlib/assert-is-ndarray-like": "^0.2.0", - "@stdlib/assert-is-plain-object": "^0.2.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.0", - "@stdlib/ndarray-base-slice-assign": "^0.2.0", - "@stdlib/ndarray-shape": "^0.2.0", - "@stdlib/slice-base-args2multislice": "^0.2.0", - "@stdlib/slice-multi": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-typed": "^0.1.0", - "@stdlib/array-zeros": "^0.1.0", - "@stdlib/complex-float32": "^0.2.0", - "@stdlib/complex-float64": "^0.2.0", - "@stdlib/complex-imag": "^0.2.0", - "@stdlib/complex-real": "^0.2.0", - "@stdlib/ndarray-array": "^0.1.0", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.0", - "@stdlib/ndarray-base-ctor": "^0.2.0", - "@stdlib/ndarray-base-empty": "^0.1.1", - "@stdlib/ndarray-base-from-scalar": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.2.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-empty": "^0.1.0", - "@stdlib/ndarray-from-scalar": "^0.2.0", - "@stdlib/ndarray-slice": "^0.1.0", - "@stdlib/ndarray-to-array": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "@stdlib/slice-ctor": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a93de39 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 82d3edfffe3dd5efb69239a45dd46b663a572702 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:51:31 +0000 Subject: [PATCH 17/47] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5fd4bed..95b84f8 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.0-esm/index.mjs'; ``` #### sliceAssign( x, y, ...s\[, options] ) @@ -240,7 +240,7 @@ import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-s import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import ndzeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; import slice from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice@esm/index.mjs'; -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.0-esm/index.mjs'; // Alias `null` to allow for more compact indexing expressions: var _ = null; From 52b2e860ec158f55ac617c5782ce4b5a28f397fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:51:31 +0000 Subject: [PATCH 18/47] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95b84f8..98cbcc1 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-slice-assign/tags). For example, + ```javascript import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.0-esm/index.mjs'; ``` @@ -240,7 +245,7 @@ import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-s import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import ndzeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; import slice from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice@esm/index.mjs'; -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.0-esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; // Alias `null` to allow for more compact indexing expressions: var _ = null; From 820fbb8535cff79f8fc53c167712449ed19aee6a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:53:27 +0000 Subject: [PATCH 19/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index 393bc84..12ecf75 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/slice-base-args2multislice": "^0.2.1", "@stdlib/slice-multi": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 58417021fd5389a26112d5dde1b3e71eb3fb7bac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:13:13 +0000 Subject: [PATCH 20/47] Remove files --- index.d.ts | 2379 ------------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 8561 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index de67e35..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function c(c,j,p){var v,f,g,u,b,y,w;if(g={strict:!0},f=arguments.length,!s(c))throw new TypeError(h("invalid argument. First argument must be an ndarray. Value: `%s`.",c));if(!s(j))throw new TypeError(h("invalid argument. Second argument must be an ndarray. Value: `%s`.",j));if(n(j))throw new Error("invalid argument. Cannot write to a read-only array.");if(e(arguments[f-1])){if(o(v=arguments[f-=1],"strict")){if(!i(v.strict))throw new TypeError(h("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",v.strict));g.strict=v.strict}if(b=l(j),2===f&&b.length>0)throw new RangeError(h("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",b.join(","),0))}if(t(p)){if(y=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else{if(r(p)){if(u=p,f>3)throw new Error("invalid invocation. Too many arguments.")}else for(u=[],w=2;w\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;+oCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,oEAAqEf,IAEnG,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,qEAAsEd,IAEpG,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAO,wDAElB,GAAKC,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,+DAAgE,SAAUZ,EAAQO,SAEhHL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,uIAAwIR,EAAGgB,KAAM,KAAO,GAEvL,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAO,+CAEZ,CACN,GAAKQ,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAO,gDAIlB,IADAX,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EAUrB,CATC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GAGtB,CAFC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,sGAAuGe,OAAQxB,EAAMG,KAClJ,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a93de39..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a75c6d3dcfe993eb3036e8567e4edecdc565b923 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:13:47 +0000 Subject: [PATCH 21/47] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 -------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ------------ 43 files changed, 4892 insertions(+), 8823 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1b4cbad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 12ecf75..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like-object": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-multi-slice": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.1", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/slice-base-args2multislice": "^0.2.1", - "@stdlib/slice-multi": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.0", - "@stdlib/array-typed": "^0.2.0", - "@stdlib/array-zeros": "^0.2.0", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-array": "^0.2.0", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-empty": "^0.2.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.0", - "@stdlib/ndarray-ctor": "^0.2.0", - "@stdlib/ndarray-empty": "^0.2.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.0", - "@stdlib/ndarray-to-array": "^0.2.0", - "@stdlib/ndarray-zeros": "^0.2.0", - "@stdlib/slice-ctor": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..87013a3 --- /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 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 2505e3ade3ca09513eac3b916fe049f4d70b4019 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:31:24 +0000 Subject: [PATCH 22/47] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0385786..c76bbbb 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.1-esm/index.mjs'; ``` #### sliceAssign( x, y, ...s\[, options] ) @@ -240,7 +240,7 @@ import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-s import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import ndzeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; import slice from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice@esm/index.mjs'; -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.1-esm/index.mjs'; // Alias `null` to allow for more compact indexing expressions: var _ = null; From 3aa81ad6b01f627b2cda43582a747d9a7e6f0134 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:31:24 +0000 Subject: [PATCH 23/47] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c76bbbb..4aad14d 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-slice-assign/tags). For example, + ```javascript import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.1-esm/index.mjs'; ``` @@ -240,7 +245,7 @@ import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-s import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import ndzeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; import slice from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice@esm/index.mjs'; -import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@v0.2.1-esm/index.mjs'; +import sliceAssign from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-slice-assign@esm/index.mjs'; // Alias `null` to allow for more compact indexing expressions: var _ = null; From e91f2d69622c0232f3104122d15f015a302d997b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:26:10 +0000 Subject: [PATCH 24/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index c193712..a1a75b9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/slice-base-args2multislice": "^0.2.1", "@stdlib/slice-multi": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From d75ede572ce540846f08baade2c56c1ab804c4dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 14:04:05 +0000 Subject: [PATCH 25/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1b4cbad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 87013a3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 59457b2433d93b7eae003e79696234a9fdf4113b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 14:04:31 +0000 Subject: [PATCH 26/47] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 -------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ------------ 44 files changed, 4892 insertions(+), 8828 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index db67bba..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:50:26.564Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f58ed1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index a1a75b9..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like-object": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-multi-slice": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.1", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/slice-base-args2multislice": "^0.2.1", - "@stdlib/slice-multi": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.2.1", - "@stdlib/array-zeros": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-empty": "^0.2.1", - "@stdlib/ndarray-base-from-scalar": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-empty": "^0.2.1", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.1", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.2.1", - "@stdlib/slice-ctor": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..208dbcb --- /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 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From fce779b9c896225d2f54a6ca63f5abdbc77874b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:34:53 +0000 Subject: [PATCH 27/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index c193712..a1a75b9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/slice-base-args2multislice": "^0.2.1", "@stdlib/slice-multi": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 0bd396383561f153217cf511df5d29159806ccdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 10:15:37 +0000 Subject: [PATCH 28/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f58ed1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 208dbcb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e7d7bfcd9be725af26867e800b64c89c69c44ef5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 10:16:12 +0000 Subject: [PATCH 29/47] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 -------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ------------ 43 files changed, 4892 insertions(+), 8829 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f58ed1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index a1a75b9..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like-object": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-multi-slice": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.1", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/slice-base-args2multislice": "^0.2.1", - "@stdlib/slice-multi": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.2.1", - "@stdlib/array-zeros": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-empty": "^0.2.1", - "@stdlib/ndarray-base-from-scalar": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-empty": "^0.2.1", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.1", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.2.1", - "@stdlib/slice-ctor": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..208dbcb --- /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 072bd76..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 528e4efba932c844712293acb02f2901d01276cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Dec 2024 01:58:06 +0000 Subject: [PATCH 30/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index d4358af..024c972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/slice-base-args2multislice": "^0.2.2", "@stdlib/slice-multi": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From d9d26c6ecc9d355abc8a0fe3d15ce8c80a683485 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Dec 2024 02:11:24 +0000 Subject: [PATCH 31/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f58ed1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 208dbcb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e295cf54dc40cd689f5b12f8ebf4da6db77e701d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Dec 2024 02:12:00 +0000 Subject: [PATCH 32/47] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ---------- 45 files changed, 4892 insertions(+), 9091 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.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e54f9cf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-09T01:54:47.237Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf6505b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 024c972..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-multi-slice": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/slice-base-args2multislice": "^0.2.2", - "@stdlib/slice-multi": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/slice-ctor": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00384fa --- /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 9135ac6..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From ea737778265f16dd5bc275bb438d8a3eee6f1a27 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 00:29:41 +0000 Subject: [PATCH 33/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index d4358af..024c972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/slice-base-args2multislice": "^0.2.2", "@stdlib/slice-multi": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From dd1c364ad343f0e596e175304f214e910f050313 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 00:30:18 +0000 Subject: [PATCH 34/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf6505b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00384fa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1382a56775fbe14e0e111366967285e8b936be77 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 00:30:45 +0000 Subject: [PATCH 35/47] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ---------- 45 files changed, 4892 insertions(+), 9090 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.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 05f6261..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-03T00:29:00.291Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5ec689e..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/slice-assign) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aaa158 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 024c972..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-multi-slice": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/slice-base-args2multislice": "^0.2.2", - "@stdlib/slice-multi": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/slice-ctor": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00384fa --- /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 9135ac6..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From e79d73e2bcb0892ad8608eed63664b218b7d3708 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:27:57 +0000 Subject: [PATCH 36/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index d4358af..024c972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/slice-base-args2multislice": "^0.2.2", "@stdlib/slice-multi": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From ac17a15519d735d04b5547f6975684423a55d1c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:00:05 +0000 Subject: [PATCH 37/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aaa158..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00384fa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b76d3b96627f488382a37d449dafc847105eede5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:00:41 +0000 Subject: [PATCH 38/47] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ---------- 45 files changed, 4892 insertions(+), 9094 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.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f801f40..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:16:52.657Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f0feeee..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/slice-assign) 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 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aaa158 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 024c972..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-multi-slice": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/slice-base-args2multislice": "^0.2.2", - "@stdlib/slice-multi": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/slice-ctor": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00384fa --- /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 9135ac6..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 50cd2c660ab5313b7147f5031f1044ac2574baf0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:02:20 +0000 Subject: [PATCH 39/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index d4358af..024c972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/slice-base-args2multislice": "^0.2.2", "@stdlib/slice-multi": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 3a4bcf6d8450c6d00d5372807885c55b062494a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:39:47 +0000 Subject: [PATCH 40/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aaa158..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00384fa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 852f179c87b62068c76bcd1ea89eecdc03131aec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:40:28 +0000 Subject: [PATCH 41/47] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ---------- 45 files changed, 4892 insertions(+), 9094 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.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ad2c45b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T01:01:48.576Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f0feeee..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/slice-assign) 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 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aaa158 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 024c972..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-multi-slice": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/slice-base-args2multislice": "^0.2.2", - "@stdlib/slice-multi": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/slice-ctor": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00384fa --- /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 9135ac6..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 666775f6a176849f741ec569d353a6e2f4b4390c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 00:58:38 +0000 Subject: [PATCH 42/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index d4358af..024c972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/slice-base-args2multislice": "^0.2.2", "@stdlib/slice-multi": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From b9fa3d874b22dac84af3e032c84cb506fe1a9886 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:17:55 +0000 Subject: [PATCH 43/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aaa158..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00384fa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fc88c43befd9a2288bbd2b56d014cba919319704 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:18:43 +0000 Subject: [PATCH 44/47] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ---------- 45 files changed, 4892 insertions(+), 9094 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.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 03dbc0d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-07T00:55:54.047Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f0feeee..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/slice-assign) 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 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aaa158 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 024c972..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-multi-slice": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/slice-base-args2multislice": "^0.2.2", - "@stdlib/slice-multi": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/slice-ctor": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00384fa --- /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 9135ac6..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); From 0dfbbd951f7cef012d9b542f6c506b40fdf0c881 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Jun 2025 01:11:37 +0000 Subject: [PATCH 45/47] Transform error messages --- lib/main.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index c35fd62..b420322 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' ); var args2multislice = require( '@stdlib/slice-base-args2multislice' ); var base = require( '@stdlib/ndarray-base-slice-assign' ); var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1jT4f', x ) ); } if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) ); + throw new TypeError( format( '1jTF1', y ) ); } if ( isReadOnly( y ) ) { - throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + throw new Error( format('1jTEs') ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( y ); if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); } } if ( isMultiSlice( s ) ) { S = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { if ( isArrayLikeObject( s ) ) { args = s; if ( nargs > 3 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1jT0m') ); } } else { args = []; @@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) { try { new MultiSlice( args[ i ] ); // eslint-disable-line no-new } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); } } } diff --git a/package.json b/package.json index d4358af..024c972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/slice-base-args2multislice": "^0.2.2", "@stdlib/slice-multi": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 269e315fb4266ba223d0043137819bf2fd376711 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Jun 2025 01:25:28 +0000 Subject: [PATCH 46/47] Remove files --- index.d.ts | 2379 ------------------------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 7226 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 768d455..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2379 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; -import { ArrayLike } from '@stdlib/types/array'; -import { MultiSlice, Slice } from '@stdlib/types/slice'; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking (default: true). - */ - strict?: boolean; -} - -/** -* Slice argument. -*/ -type SliceArgument = Slice | number | null | undefined; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, options?: Options ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, s: ArrayLike, options?: Options ): float64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float64ndarray, ...slices: Array ): float64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, options?: Options ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, s: ArrayLike, options?: Options ): float32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: float32ndarray, ...slices: Array ): float32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, options?: Options ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, s: ArrayLike, options?: Options ): int32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int32ndarray, ...slices: Array ): int32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, options?: Options ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, s: ArrayLike, options?: Options ): int16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int16ndarray, ...slices: Array ): int16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, options?: Options ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, s: ArrayLike, options?: Options ): int8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: int8ndarray, ...slices: Array ): int8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, options?: Options ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, s: ArrayLike, options?: Options ): uint32ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint32ndarray, ...slices: Array ): uint32ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, options?: Options ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, s: ArrayLike, options?: Options ): uint16ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint16ndarray, ...slices: Array ): uint16ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, options?: Options ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, s: ArrayLike, options?: Options ): uint8ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8ndarray, ...slices: Array ): uint8ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, options?: Options ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, s: ArrayLike, options?: Options ): uint8cndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices -slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: uint8cndarray, ...slices: Array ): uint8cndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, options?: Options ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, s: ArrayLike, options?: Options ): complex128ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex128ndarray, ...slices: Array ): complex128ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, options?: Options ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, s: ArrayLike, options?: Options ): complex64ndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var typedarray = require( '@stdlib/array-typed' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ndarray, y: complex64ndarray, ...slices: Array ): complex64ndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, options?: Options ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, s: ArrayLike, options?: Options ): genericndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: genericndarray, ...slices: Array ): genericndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - multi-slice object for the output array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, options?: Options ): typedndarray; - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - array of slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, [ s0, s1, s2 ] ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, s: ArrayLike, options?: Options ): typedndarray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array view to which elements will be assigned. -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param slices - slice arguments -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s0, s1, s2 ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] -*/ -declare function sliceAssign( x: ndarray, y: typedndarray, ...slices: Array ): typedndarray; - - -// EXPORTS // - -export = sliceAssign; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aaa158..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00384fa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 312f259e7455e195623a3c378fc2cf958c738aaa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Jun 2025 01:26:24 +0000 Subject: [PATCH 47/47] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 93 +- SECURITY.md | 5 - benchmark/benchmark.call_signatures.js | 133 - benchmark/benchmark.js | 1864 ------- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 234 - examples/index.js | 95 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 79 - lib/main.js | 177 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2751 ---------- 45 files changed, 4892 insertions(+), 9094 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.call_signatures.js delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e461b04..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-23T01:02:34.005Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f0feeee..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/slice-assign) 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 05f9e55..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/slice-assign) 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 3aad2f2..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: '27 3 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -354,7 +345,7 @@ var a6 = ndarray2array( y ); ## 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]. @@ -417,25 +408,25 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-slice-assign/main/LICENSE -[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor +[@stdlib/slice/ctor]: https://github.com/stdlib-js/slice-ctor/tree/esm -[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi +[@stdlib/slice/multi]: https://github.com/stdlib-js/slice-multi/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice +[@stdlib/ndarray/slice]: https://github.com/stdlib-js/ndarray-slice/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.call_signatures.js b/benchmark/benchmark.call_signatures.js deleted file mode 100644 index 360cf33..0000000 --- a/benchmark/benchmark.call_signatures.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::2d,base,multislice', function benchmark( b ) { - var values; - var x; - var v; - var s; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,separate_arguments', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], null, null ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,array', function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = scalar2ndarray( 3, { - 'dtype': 'int8' - }); - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sliceAssign( x, values[ i%values.length ], [ null, null ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5758184..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1864 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var baseEmpty = require( '@stdlib/ndarray-base-empty' ); -var baseZeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-empty' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::0d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [], 'row-major' ), - baseZeros( 'float32', [], 'row-major' ), - baseZeros( 'int32', [], 'row-major' ), - baseZeros( 'complex128', [], 'row-major' ), - baseZeros( 'generic', [], 'row-major' ) - ]; - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::0d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [], { 'dtype': 'float64' } ), - zeros( [], { 'dtype': 'float32' } ), - zeros( [], { 'dtype': 'int32' } ), - zeros( [], { 'dtype': 'complex128' } ), - zeros( [], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2 ], 'row-major' ), - baseZeros( 'float32', [ 2 ], 'row-major' ), - baseZeros( 'int32', [ 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2 ], 'row-major' ), - baseZeros( 'generic', [ 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1 ], { 'dtype': 'float64' } ), - empty( [ 1 ], { 'dtype': 'float32' } ), - empty( [ 1 ], { 'dtype': 'int32' } ), - empty( [ 1 ], { 'dtype': 'complex128' } ), - empty( [ 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'int32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ) ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,reduced', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( 0, 1, 0, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [], 'row-major' ), - baseEmpty( 'float32', [], 'row-major' ), - baseEmpty( 'int32', [], 'row-major' ), - baseEmpty( 'complex128', [], 'row-major' ), - baseEmpty( 'generic', [], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) { - var values; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [], { 'dtype': 'float64' } ), - empty( [], { 'dtype': 'float32' } ), - empty( [], { 'dtype': 'int32' } ), - empty( [], { 'dtype': 'complex128' } ), - empty( [], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, null, null ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - values = [ - baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), - baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) - ]; - y = [ - baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), - baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) - ]; - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) { - var values; - var opts; - var v; - var y; - var s; - var i; - var j; - - /* eslint-disable object-curly-newline */ - - values = [ - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), - empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) - ]; - y = [ - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline */ - - s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null ); - opts = { - 'strict': false - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % values.length; - v = sliceAssign( values[ j ], y[ j ], s, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( v ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9979247..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/slice-assign" -%% click B href "https://github.com/stdlib-js/ndarray-slice-assign/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-slice-assign/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-slice-assign/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-slice-assign/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-slice-assign/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/slice-assign -[production-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-slice-assign/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-slice-assign/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-slice-assign/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 338cc47..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import sliceAssign from '../docs/types/index'; -export = sliceAssign; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 732fde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var h=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=h(function(k,c){"use strict";var m=require("@stdlib/assert-is-ndarray-like"),d=require("@stdlib/assert-is-multi-slice"),w=require("@stdlib/assert-is-array-like-object"),f=require("@stdlib/assert-is-plain-object"),p=require("@stdlib/assert-is-boolean").isPrimitive,q=require("@stdlib/ndarray-base-assert-is-read-only"),y=require("@stdlib/assert-has-own-property"),b=require("@stdlib/slice-multi"),S=require("@stdlib/slice-base-args2multislice"),E=require("@stdlib/ndarray-base-slice-assign"),T=require("@stdlib/ndarray-shape"),s=require("@stdlib/string-format");function O(t,r,o){var n,i,u,a,l,v,e;if(u={strict:!0},i=arguments.length,!m(t))throw new TypeError(s("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!m(r))throw new TypeError(s("invalid argument. Second argument must be an ndarray. Value: `%s`.",r));if(q(r))throw new Error("invalid argument. Cannot write to a read-only array.");if(f(arguments[i-1])){if(i-=1,n=arguments[i],y(n,"strict")){if(!p(n.strict))throw new TypeError(s("invalid option. `%s` option must be a boolean. Option: `%s`.","strict",n.strict));u.strict=n.strict}if(l=T(r),i===2&&l.length>0)throw new RangeError(s("invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.",l.join(","),0))}if(d(o)){if(v=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else{if(w(o)){if(a=o,i>3)throw new Error("invalid invocation. Too many arguments.")}else for(a=[],e=2;e\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot write to a read-only array.' );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( 'invalid invocation. Too many arguments.' );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nmodule.exports = sliceAssign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.\n*\n* @module @stdlib/ndarray-slice-assign\n*\n* @example\n* var Slice = require( '@stdlib/slice-ctor' );\n* var MultiSlice = require( '@stdlib/slice-multi' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndzeros = require( '@stdlib/ndarray-zeros' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var sliceAssign = require( '@stdlib/ndarray-slice-assign' );\n*\n* // Define an input array:\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAe,QAAS,+BAAgC,EACxDC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,0CAA2C,EACjEC,EAAa,QAAS,iCAAkC,EACxDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAkB,QAAS,oCAAqC,EAChEC,EAAO,QAAS,mCAAoC,EACpDC,EAAW,QAAS,uBAAwB,EAC5CC,EAAS,QAAS,uBAAwB,EAuE9C,SAASC,EAAaC,EAAGC,EAAGC,EAAI,CAC/B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACN,OAAU,EACX,EACAD,EAAQ,UAAU,OACb,CAACjB,EAAea,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAE,CAAE,EAEvG,GAAK,CAACb,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAE,CAAE,EAExG,GAAKT,EAAYS,CAAE,EAClB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,GAAKX,EAAe,UAAWc,EAAM,CAAE,CAAE,EAAI,CAG5C,GAFAA,GAAS,EACTD,EAAU,UAAWC,CAAM,EACtBX,EAAYU,EAAS,QAAS,EAAI,CACtC,GAAK,CAACZ,EAAWY,EAAQ,MAAO,EAC/B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,SAAUK,EAAQ,MAAO,CAAE,EAEzHE,EAAK,OAASF,EAAQ,MACvB,CAEA,GADAI,EAAKV,EAAUI,CAAE,EACZG,IAAU,GAAKG,EAAG,OAAS,EAC/B,MAAM,IAAI,WAAYT,EAAQ,uIAAwIS,EAAG,KAAM,GAAI,EAAG,CAAE,CAAE,CAE5L,CACA,GAAKnB,EAAcc,CAAE,GAEpB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAEtD,CACN,GAAKf,EAAmBa,CAAE,GAEzB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAI,MAAO,yCAA0C,MAI5D,KADAE,EAAO,CAAC,EACFG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAK,KAAM,UAAWG,CAAE,CAAE,EAG5B,GAAI,CACHD,EAAIb,EAAiBW,CAAK,CAC3B,OAAUI,EAAM,CAEf,IAAMD,EAAI,EAAGA,EAAIH,EAAK,OAAQG,IAC7B,GAAI,CACH,IAAIf,EAAYY,EAAMG,CAAE,CAAE,CAC3B,OAAUC,EAAM,CACf,MAAM,IAAI,UAAWZ,EAAQ,sGAAuG,OAAQQ,EAAMG,CAAE,CAAE,CAAE,CAAE,CAC3J,CAEF,CACD,CACA,OAAOb,EAAMI,EAAGC,EAAGO,EAAGH,EAAK,MAAO,CACnC,CAKAnB,EAAO,QAAUa,ICvGjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isMultiSlice", "isArrayLikeObject", "isPlainObject", "isBoolean", "isReadOnly", "hasOwnProp", "MultiSlice", "args2multislice", "base", "getShape", "format", "sliceAssign", "x", "y", "s", "options", "nargs", "opts", "args", "sh", "S", "i", "err", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0966f14..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, y, ...s[, options] ) - Assigns element values from a broadcasted input ndarray to corresponding - elements in an output ndarray view. - - The function supports three (mutually exclusive) means of providing slice - arguments: - - 1. Providing a single MultiSlice object. - 2. Providing a single array containing slice arguments. - 3. Providing slice arguments as separate arguments. - - An individual slice argument must be either a Slice, an integer, null, or - undefined. - - In all cases, the number of slice dimensions must match the number of output - array dimensions. - - If providing a MultiSlice object or an array of slice arguments, no other - slice arguments should be provided. - - Mixing function invocation styles (e.g., providing multiple MultiSlice - objects or providing an array of slice arguments followed by additional - slice arguments) is not supported. - - Parameters - ---------- - x: ndarray - Input array. The input array must be broadcast compatible with the - output array view and must have a data type which can be safely cast to - the output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ndarray - Output array. The output array must be writable. - - s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike - Slice arguments. - - options: Object (optional) - Options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. - Default: true. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] ) - - > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 ) - - > var s = new {{alias:@stdlib/slice/multi}}( null, 1 ) - - > var out = {{alias}}( x, y, s ) - - > var bool = ( out === y ) - true - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6225c0a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import zeros = require( '@stdlib/ndarray-zeros' ); -import MultiSlice = require( '@stdlib/slice-multi' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - const s = new MultiSlice( null, null ); - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': false } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': false } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': false } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': false } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': false } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': false } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': false } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': false } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': false } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': false } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': false } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray - - sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, { 'strict': true } ); // $ExpectType float64ndarray - sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, { 'strict': true } ); // $ExpectType float32ndarray - sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, { 'strict': true } ); // $ExpectType complex128ndarray - sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, { 'strict': true } ); // $ExpectType complex64ndarray - sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, { 'strict': true } ); // $ExpectType int32ndarray - sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, { 'strict': true } ); // $ExpectType int16ndarray - sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, { 'strict': true } ); // $ExpectType int8ndarray - sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, { 'strict': true } ); // $ExpectType uint32ndarray - sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, { 'strict': true } ); // $ExpectType uint16ndarray - sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, { 'strict': true } ); // $ExpectType uint8ndarray - sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, { 'strict': true } ); // $ExpectType uint8cndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( '10', y, s ); // $ExpectError - sliceAssign( 10, y, s ); // $ExpectError - sliceAssign( false, y, s ); // $ExpectError - sliceAssign( true, y, s ); // $ExpectError - sliceAssign( null, y, s ); // $ExpectError - sliceAssign( [], y, s ); // $ExpectError - sliceAssign( {}, y, s ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s ); // $ExpectError - - sliceAssign( '10', y, s, {} ); // $ExpectError - sliceAssign( 10, y, s, {} ); // $ExpectError - sliceAssign( false, y, s, {} ); // $ExpectError - sliceAssign( true, y, s, {} ); // $ExpectError - sliceAssign( null, y, s, {} ); // $ExpectError - sliceAssign( [], y, s, {} ); // $ExpectError - sliceAssign( {}, y, s, {} ); // $ExpectError - sliceAssign( ( x: number ): number => x, y, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, '10', s ); // $ExpectError - sliceAssign( x, 10, s ); // $ExpectError - sliceAssign( x, false, s ); // $ExpectError - sliceAssign( x, true, s ); // $ExpectError - sliceAssign( x, null, s ); // $ExpectError - sliceAssign( x, [], s ); // $ExpectError - sliceAssign( x, {}, s ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s ); // $ExpectError - - sliceAssign( x, '10', s, {} ); // $ExpectError - sliceAssign( x, 10, s, {} ); // $ExpectError - sliceAssign( x, false, s, {} ); // $ExpectError - sliceAssign( x, true, s, {} ); // $ExpectError - sliceAssign( x, null, s, {} ); // $ExpectError - sliceAssign( x, [], s, {} ); // $ExpectError - sliceAssign( x, {}, s, {} ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, s, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid slice argument... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - - sliceAssign( x, y, null, '5' ); // $ExpectError - sliceAssign( x, y, null, false ); // $ExpectError - sliceAssign( x, y, null, true ); // $ExpectError - sliceAssign( x, y, null, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, false ); // $ExpectError - sliceAssign( x, y, null, 1, true ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5' ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ] ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x ); // $ExpectError - - sliceAssign( x, y, null, '5', {} ); // $ExpectError - sliceAssign( x, y, null, false, {} ); // $ExpectError - sliceAssign( x, y, null, true, {} ); // $ExpectError - sliceAssign( x, y, null, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, ( x: number ): number => x, {} ); // $ExpectError - - sliceAssign( x, y, null, 1, undefined, '5', {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, false, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, true, {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, [ '5' ], {} ); // $ExpectError - sliceAssign( x, y, null, 1, undefined, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, '5' ); // $ExpectError - sliceAssign( x, y, s, 5 ); // $ExpectError - sliceAssign( x, y, s, null ); // $ExpectError - sliceAssign( x, y, s, true ); // $ExpectError - sliceAssign( x, y, s, false ); // $ExpectError - sliceAssign( x, y, s, [ '5' ] ); // $ExpectError - sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign( x, y, s, { 'strict': '5' } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': 5 } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': null } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': [ '5' ] } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': {} } ); // $ExpectError - sliceAssign( x, y, s, { 'strict': ( 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 ] ); - const y = empty( 'float64', [ 2, 2 ], 'row-major' ); - const s = new MultiSlice( null, null ); - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, y, s, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 388319b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 new-cap */ - -'use strict'; - -var E = require( '@stdlib/slice-multi' ); -var scalar2ndarray = require( '@stdlib/ndarray-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndzeros = require( '@stdlib/ndarray-zeros' ); -var slice = require( '@stdlib/ndarray-slice' ); -var sliceAssign = require( './../lib' ); - -// Alias `null` to allow for more compact indexing expressions: -var _ = null; - -// Create an output ndarray: -var y = ndzeros( [ 3, 3, 3 ] ); - -// Update each matrix... -var s1 = E( 0, _, _ ); -sliceAssign( scalar2ndarray( 100 ), y, s1 ); - -var a1 = ndarray2array( slice( y, s1 ) ); -console.log( a1 ); -// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ] - -var s2 = E( 1, _, _ ); -sliceAssign( scalar2ndarray( 200 ), y, s2 ); - -var a2 = ndarray2array( slice( y, s2 ) ); -console.log( a2 ); -// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ] - -var s3 = E( 2, _, _ ); -sliceAssign( scalar2ndarray( 300 ), y, s3 ); - -var a3 = ndarray2array( slice( y, s3 ) ); -console.log( a3 ); -// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ] - -// Update the second rows in each matrix: -var s4 = E( _, 1, _ ); -sliceAssign( scalar2ndarray( 400 ), y, s4 ); - -var a4 = ndarray2array( slice( y, s4 ) ); -console.log( a4 ); -// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ] - -// Update the second columns in each matrix: -var s5 = E( _, _, 1 ); -sliceAssign( scalar2ndarray( 500 ), y, s5 ); - -var a5 = ndarray2array( slice( y, s5 ) ); -console.log( a5 ); -// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ] - -// Return the contents of the entire ndarray: -var a6 = ndarray2array( y ); -console.log( a6 ); -/* => - [ - [ - [ 100, 500, 100 ], - [ 400, 500, 400 ], - [ 100, 500, 100 ] - ], - [ - [ 200, 500, 200 ], - [ 400, 500, 400 ], - [ 200, 500, 200 ] - ], - [ - [ 300, 500, 300 ], - [ 400, 500, 400 ], - [ 300, 500, 300 ] - ] - ] -*/ diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index c0436ce..768d455 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aaa158 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-multi-slice@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like-object@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-read-only@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-multi@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/slice-base-args2multislice@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-assign@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function p(p,a,c){var f,v,g,b,w,x,y;if(g={strict:!0},v=arguments.length,!s(p))throw new TypeError(h("1jT4f",p));if(!s(a))throw new TypeError(h("1jTF1",a));if(n(a))throw new Error(h("1jTEs"));if(e(arguments[v-1])){if(o(f=arguments[v-=1],"strict")){if(!i(f.strict))throw new TypeError(h("1jT2o","strict",f.strict));g.strict=f.strict}if(w=l(a),2===v&&w.length>0)throw new RangeError(h("1jTEt",w.join(","),0))}if(t(c)){if(x=c,v>3)throw new Error(h("1jT0m"))}else{if(r(c)){if(b=c,v>3)throw new Error(h("1jT0m"))}else for(b=[],y=2;y\n*\n* var sh = x.shape;\n* // returns [ 3, 2 ]\n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* // Define an output array:\n* var y = ndzeros( [ 2, 3, 2 ], {\n* 'dtype': x.dtype\n* });\n*\n* // Create a slice:\n* var s0 = null;\n* var s1 = new Slice( null, null, -1 );\n* var s2 = new Slice( null, null, -1 );\n* var s = new MultiSlice( s0, s1, s2 );\n* // returns \n*\n* // Perform assignment:\n* var out = sliceAssign( x, y, s );\n* // returns \n*\n* var bool = ( out === y );\n* // returns true\n*\n* arr = ndarray2array( y );\n* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]\n*/\nfunction sliceAssign( x, y, s ) {\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar args;\n\tvar sh;\n\tvar S;\n\tvar i;\n\n\topts = {\n\t\t'strict': true\n\t};\n\tnargs = arguments.length;\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1jT4f', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( '1jTF1', y ) );\n\t}\n\tif ( isReadOnly( y ) ) {\n\t\tthrow new Error( format('1jTEs') );\n\t}\n\tif ( isPlainObject( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\toptions = arguments[ nargs ];\n\t\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\t\tif ( !isBoolean( options.strict ) ) {\n\t\t\t\tthrow new TypeError( format( '1jT2o', 'strict', options.strict ) );\n\t\t\t}\n\t\t\topts.strict = options.strict;\n\t\t}\n\t\tsh = getShape( y );\n\t\tif ( nargs === 2 && sh.length > 0 ) {\n\t\t\tthrow new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );\n\t\t}\n\t}\n\tif ( isMultiSlice( s ) ) {\n\t\tS = s;\n\t\tif ( nargs > 3 ) {\n\t\t\tthrow new Error( format('1jT0m') );\n\t\t}\n\t} else {\n\t\tif ( isArrayLikeObject( s ) ) {\n\t\t\targs = s;\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthrow new Error( format('1jT0m') );\n\t\t\t}\n\t\t} else {\n\t\t\targs = [];\n\t\t\tfor ( i = 2; i < nargs; i++ ) {\n\t\t\t\targs.push( arguments[ i ] );\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tS = args2multislice( args );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t// Search for the first offending value...\n\t\t\tfor ( i = 0; i < args.length; i++ ) {\n\t\t\t\ttry {\n\t\t\t\t\tnew MultiSlice( args[ i ] ); // eslint-disable-line no-new\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( '1jTEu', String( args[ i ] ) ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn base( x, y, S, opts.strict );\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n"],"names":["sliceAssign","x","y","s","options","nargs","opts","args","sh","S","i","strict","arguments","length","isndarrayLike","TypeError","format","isReadOnly","Error","isPlainObject","hasOwnProp","isBoolean","getShape","RangeError","join","isMultiSlice","isArrayLikeObject","push","args2multislice","err","MultiSlice","String","base"],"mappings":";;wpCAwGA,SAASA,EAAaC,EAAGC,EAAGC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAJ,EAAO,CACNK,QAAU,GAEXN,EAAQO,UAAUC,QACZC,EAAeb,GACpB,MAAM,IAAIc,UAAWC,EAAQ,QAASf,IAEvC,IAAMa,EAAeZ,GACpB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAEvC,GAAKe,EAAYf,GAChB,MAAM,IAAIgB,MAAOF,EAAO,UAEzB,GAAKG,EAAeP,UAAWP,EAAM,IAAQ,CAG5C,GAAKe,EADLhB,EAAUQ,UADVP,GAAS,GAEiB,UAAa,CACtC,IAAMgB,EAAWjB,EAAQO,QACxB,MAAM,IAAII,UAAWC,EAAQ,QAAS,SAAUZ,EAAQO,SAEzDL,EAAKK,OAASP,EAAQO,MACtB,CAED,GADAH,EAAKc,EAAUpB,GACA,IAAVG,GAAeG,EAAGK,OAAS,EAC/B,MAAM,IAAIU,WAAYP,EAAQ,QAASR,EAAGgB,KAAM,KAAO,GAExD,CACD,GAAKC,EAActB,IAElB,GADAM,EAAIN,EACCE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,cAEnB,CACN,GAAKU,EAAmBvB,IAEvB,GADAI,EAAOJ,EACFE,EAAQ,EACZ,MAAM,IAAIa,MAAOF,EAAO,eAIzB,IADAT,EAAO,GACDG,EAAI,EAAGA,EAAIL,EAAOK,IACvBH,EAAKoB,KAAMf,UAAWF,IAGxB,IACCD,EAAImB,EAAiBrB,EACrB,CAAC,MAAQsB,GAET,IAAMnB,EAAI,EAAGA,EAAIH,EAAKM,OAAQH,IAC7B,IACC,IAAIoB,EAAYvB,EAAMG,GACtB,CAAC,MAAQmB,GACT,MAAM,IAAId,UAAWC,EAAQ,QAASe,OAAQxB,EAAMG,KACpD,CAEF,CACD,CACD,OAAOsB,EAAM/B,EAAGC,EAAGO,EAAGH,EAAKK,OAC5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 17122fc..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @module @stdlib/ndarray-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var sliceAssign = require( '@stdlib/ndarray-slice-assign' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ - -// 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 b420322..0000000 --- a/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isMultiSlice = require( '@stdlib/assert-is-multi-slice' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var args2multislice = require( '@stdlib/slice-base-args2multislice' ); -var base = require( '@stdlib/ndarray-base-slice-assign' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. -* -* @param {ndarray} x - input array -* @param {ndarray} y - output array -* @param {...*} s - slice arguments -* @param {Options} [options] - options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @throws {TypeError} first argument must be an ndarray -* @throws {TypeError} second argument must be an ndarray -* @throws {TypeError} must provide valid slice arguments -* @throws {Error} insufficient arguments -* @throws {Error} too many arguments -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {RangeError} number of slice dimensions must match the number of output array dimensions -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @throws {Error} cannot write to a read-only ndarray -* @returns {ndarray} output array -* -* @example -* var Slice = require( '@stdlib/slice-ctor' ); -* var MultiSlice = require( '@stdlib/slice-multi' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndzeros = require( '@stdlib/ndarray-zeros' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* // Define an input array: -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var sh = x.shape; -* // returns [ 3, 2 ] -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* // Define an output array: -* var y = ndzeros( [ 2, 3, 2 ], { -* 'dtype': x.dtype -* }); -* -* // Create a slice: -* var s0 = null; -* var s1 = new Slice( null, null, -1 ); -* var s2 = new Slice( null, null, -1 ); -* var s = new MultiSlice( s0, s1, s2 ); -* // returns -* -* // Perform assignment: -* var out = sliceAssign( x, y, s ); -* // returns -* -* var bool = ( out === y ); -* // returns true -* -* arr = ndarray2array( y ); -* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] -*/ -function sliceAssign( x, y, s ) { - var options; - var nargs; - var opts; - var args; - var sh; - var S; - var i; - - opts = { - 'strict': true - }; - nargs = arguments.length; - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1jT4f', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( '1jTF1', y ) ); - } - if ( isReadOnly( y ) ) { - throw new Error( format('1jTEs') ); - } - if ( isPlainObject( arguments[ nargs-1 ] ) ) { - nargs -= 1; - options = arguments[ nargs ]; - if ( hasOwnProp( options, 'strict' ) ) { - if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( '1jT2o', 'strict', options.strict ) ); - } - opts.strict = options.strict; - } - sh = getShape( y ); - if ( nargs === 2 && sh.length > 0 ) { - throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) ); - } - } - if ( isMultiSlice( s ) ) { - S = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - if ( isArrayLikeObject( s ) ) { - args = s; - if ( nargs > 3 ) { - throw new Error( format('1jT0m') ); - } - } else { - args = []; - for ( i = 2; i < nargs; i++ ) { - args.push( arguments[ i ] ); - } - } - try { - S = args2multislice( args ); - } catch ( err ) { // eslint-disable-line no-unused-vars - // Search for the first offending value... - for ( i = 0; i < args.length; i++ ) { - try { - new MultiSlice( args[ i ] ); // eslint-disable-line no-new - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( '1jTEu', String( args[ i ] ) ) ); - } - } - } - } - return base( x, y, S, opts.strict ); -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/package.json b/package.json index 024c972..2f0aed0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-multi-slice": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-base-slice-assign": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/slice-base-args2multislice": "^0.2.2", - "@stdlib/slice-multi": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-from-scalar": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-from-scalar": "^0.2.1", - "@stdlib/ndarray-slice": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/slice-ctor": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00384fa --- /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 9135ac6..0000000 --- a/test/test.js +++ /dev/null @@ -1,2751 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline, max-len, max-lines */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isComplexDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); -var MultiSlice = require( '@stdlib/slice-multi' ); -var Slice = require( '@stdlib/slice-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var azeros = require( '@stdlib/array-zeros' ); -var typedarray = require( '@stdlib/array-typed' ); -var array = require( '@stdlib/ndarray-array' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var baseCtor = require( '@stdlib/ndarray-base-ctor' ); -var ctor = require( '@stdlib/ndarray-ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (multislice)', function test( t ) { - var values; - var y; - var s; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (array)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var y; - var i; - - y = zeros( [ 2, 2 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (multislice)', function test( t ) { - var values; - var x; - var s; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - s = new MultiSlice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, s ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (array)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an ndarray (slice arguments)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, null, null ); - }; - } -}); - -tape( 'the function throws an error if provided a read-only output array (multislice)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, new MultiSlice( null, null ) ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (array)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, [ null, null ] ); - } -}); - -tape( 'the function throws an error if provided a read-only output array (slice arguments)', function test( t ) { - var x; - var y; - - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 2, 2 ], { - 'readonly': true - }); - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - sliceAssign( x, y, null, null ); - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ new Slice() ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - true, - false, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = new Slice(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = new MultiSlice( null ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (array)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = [ null ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=1)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `strict` option which is not a boolean (slice argument, ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, s, { - 'strict': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=2)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid slice argument (ndims=3)', function test( t ) { - var values; - var x; - var y; - var s; - var i; - - values = [ - '5', - NaN, - [], - function noop() {} - ]; - x = scalar2ndarray( 2.0, 'float64', 'row-major' ); - y = zeros( [ 1, 1, 1 ] ); - s = null; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, y, s, s, value ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (multislice, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null, null ), - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (array, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, {} ); - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ] ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ] ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ] ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (slice arguments, options)', function test( t ) { - var values; - var slices; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [] ), - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - slices = [ - [ null ], - [ null, null, null ], - [ null ], - [ null, null ], - [ null, null, null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - if ( s.length === 1 ) { - return sliceAssign( x, y, s[ 0 ], {} ); - } - if ( s.length === 2 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], {} ); - } - if ( s.length === 3 ) { - return sliceAssign( x, y, s[ 0 ], s[ 1 ], s[ 2 ], {} ); - } - }; - } -}); - -tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (no slice arguments, options)', function test( t ) { - var values; - var x; - var i; - - x = scalar2ndarray( 0, 'float64', 'row-major' ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided shape (' + values[ i ].shape.join( ',' ) + ')' ); - } - t.end(); - - function badValue( y ) { - return function badValue() { - sliceAssign( x, y, {} ); - }; - } -}); - -tape( 'by default, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) { - var values; - var slices; - var x; - var s; - var i; - - x = zeros( [] ); - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( y, s ) { - return function badValues() { - sliceAssign( x, y, s, { - 'strict': true - }); - }; - } -}); - -tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) { - var actual; - var values; - var slices; - var z; - var x; - var s; - var v; - var i; - - x = scalar2ndarray( 3, 'uint8', 'row-major' ); - - values = [ - zeros( [ 1 ], { 'dtype': 'float64' } ), - zeros( [ 1, 1 ], { 'dtype': 'float32' } ), - zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), - zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), - zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) - ]; - - s = new Slice( 10, 20, 1 ); - slices = [ - new MultiSlice( 10 ), - new MultiSlice( null, s ), - new MultiSlice( s, null, null ), - new MultiSlice( s, s, null, null ), - new MultiSlice( 0, null, null, null, 10 ) - ]; - for ( i = 0; i < values.length; i++ ) { - v = values[ i ]; - actual = sliceAssign( x, v, slices[ i ], { - 'strict': false - }); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' ); - t.strictEqual( actual.dtype, v.dtype, 'returns expected value' ); - - z = actual.iget( 0 ); - if ( v.dtype === 'complex128' ) { - t.strictEqual( real( z ), 0, 'returns expected value' ); - t.strictEqual( imag( z ), 0, 'returns expected value' ); - } else { - t.strictEqual( z, 0, 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 10 ] ), - zeros( [ 10, 10 ] ), - zeros( [ 10, 10, 10 ] ), - zeros( [ 10, 10 ] ) - ]; - - values = [ - zeros( [ 2 ] ), - zeros( [ 2, 2 ] ), - zeros( [ 2, 2, 2 ] ), - zeros( [ 2, 2, 2, 2 ] ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( 0, 0, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) { - var values; - var slices; - var x; - var i; - - x = [ - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) - ]; - - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2, 2 ], { 'dtype': 'float32' } ), - zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) - ]; - - slices = [ - new MultiSlice( null ), - new MultiSlice( null, null ), - new MultiSlice( null, null, null ), - new MultiSlice( null, null, null, null ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() ); - } - t.end(); - - function badValues( x, y, s ) { - return function badValues() { - sliceAssign( x, y, s ); - }; - } -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, multislice)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, array)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - s = []; - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, slice arguments)', function test( t ) { - var actual; - var x; - var y; - - x = scalar2ndarray( 3.14, 'float64', 'row-major' ); - y = scalar2ndarray( 0.0, x.dtype, x.order ); - - actual = sliceAssign( x, y ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3.14, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var x; - var y; - var s; - - x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' ); - y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order ); - s = new MultiSlice(); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get(), 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) { - var expected; - var actual; - var values; - var slices; - var idx; - var x; - var y; - var s; - var i; - - x = [ - scalar2ndarray( 100, 'float64', 'row-major' ), - scalar2ndarray( 50, 'float32', 'row-major' ), - scalar2ndarray( 200, 'int32', 'row-major' ), - scalar2ndarray( 300, 'uint32', 'row-major' ) - ]; - - values = [ - array( typedarray( zeroTo( 4 ), 'float64' ), { - 'shape': [ 2, 2 ], - 'dtype': 'float64' - }), - array( typedarray( zeroTo( 8 ), 'float32' ), { - 'shape': [ 2, 2, 2 ], - 'dtype': 'float32' - }), - array( typedarray( zeroTo( 2 ), 'int32' ), { - 'shape': [ 2 ], - 'dtype': 'int32' - }), - array( typedarray( zeroTo( 16 ), 'uint32' ), { - 'shape': [ 2, 2, 2, 2 ], - 'dtype': 'uint32' - }) - ]; - idx = [ - [ 0, 1 ], - [ 0, 1, 0 ], - [ 0 ], - [ 0, 1, 0, 1 ] - ]; - slices = [ - MultiSlice.apply( null, idx[ 0 ] ), - MultiSlice.apply( null, idx[ 1 ] ), - MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) - ]; - expected = [ - 100, - 50, - 200, - 300 - ]; - for ( i = 0; i < values.length; i++ ) { - y = values[ i ]; - s = slices[ i ]; - actual = sliceAssign( x[ i ], y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var dt; - var o; - var x; - var y; - var s; - - ord = 'row-major'; - dt = 'float64'; - buf = typedarray( zeroTo( 30 ), dt ); - - sh = [ 6 ]; - st = [ 2 ]; - o = 5; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1 ); - - x = scalar2ndarray( 3.14, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' ); - - sh = [ 3, 3 ]; - st = [ 6, 2 ]; - o = 10; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 0, 1 ); - - x = scalar2ndarray( 6.28, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ 12, 6, 2 ]; - o = 3; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( 9.52, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' ); - - sh = [ 2, 2, 3 ]; - st = [ -12, -6, -2 ]; - o = 25; - y = new ctor( dt, buf, sh, st, o, ord ); - s = new MultiSlice( 1, 1, 2 ); - - x = scalar2ndarray( -1.0, dt, ord ); - - actual = sliceAssign( x, y, s ); - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( null, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, null, -2 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 1, null, 3 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = [ new Slice( 4, 1, -1 ) ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = null; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 4, 6, 8, 10, 12, 14 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 14, 0, 10, 0, 6 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, null, -2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 12, 0, 8, 0, 4, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 1, null, 3 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 6, 0, 0, 12, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new Slice( 4, 1, -1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 12, 10, 8, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, multislice)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, array)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = [ null, null ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = [ s0, s1 ]; - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, slice arguments)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = null; - s1 = null; - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 4, 6, 8 ], - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 26, 0, 22 ], - [ 0, 0, 0 ], - [ 14, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 18, 16, 0 ], - [ 0, 0, 0 ], - [ 6, 4, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - actual = sliceAssign( x, y, s0, s1 ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 16, 18, 0 ], - [ 10, 12, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 30 ), 'float64' ); - - // Second column: - x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s = new MultiSlice( null, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 7, 0 ], - [ 0, 13, 0 ], - [ 0, 19, 0 ], - [ 0, 25, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 15, 0, 11 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = 2; - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 21 ], - [ 0, 0, 0 ], - [ 0, 0, 9 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a row: - x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ] - - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 11, 13, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Full slice: - x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 12, 14 ], - [ 16, 18, 20 ], - [ 22, 24, 26 ], - [ 28, 30, 32 ] - ], - [ - [ 34, 36, 38 ], - [ 40, 42, 44 ], - [ 46, 48, 50 ], - [ 52, 54, 56 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 56, 0, 52 ], - [ 0, 0, 0 ], - [ 44, 0, 40 ] - ], - [ - [ 0, 0, 0 ], - [ 32, 0, 28 ], - [ 0, 0, 0 ], - [ 20, 0, 16 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 24, 22, 0 ], - [ 0, 0, 0 ], - [ 12, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 48, 46, 0 ], - [ 0, 0, 0 ], - [ 36, 34, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 22, 24, 0 ], - [ 16, 18, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( zeroTo( 100 ), 'float64' ); - - // Second row and second column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s = new MultiSlice( null, 1, 1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 67, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 91, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 69, 67, 65 ], - [ 0, 0, 0 ], - [ 57, 55, 53 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements: - x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = new Slice( 1, null, -1 ); - s1 = 2; - s2 = new Slice( null, null, 2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 83, 0, 87 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 59, 0, 63 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set part of a column: - x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ] - - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' ); - - s0 = 1; - s1 = new Slice( 0, 2, 1 ); - s2 = 2; - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 65 ], - [ 0, 0, 71 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=1)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 10, 10, 10, 10, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( null, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 10, 0, 10 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element, starting from second-to-last element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, null, -2 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 10, 0, 10, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Skip every three elements, starting from second element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 1, null, 3 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 10, 0, 0, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' ); - - s = new MultiSlice( new Slice( 4, 1, -1 ) ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ 0, 0, 10, 10, 10, 0 ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=2)', function test( t ) { - var expected; - var actual; - var ybuf; - var s0; - var s1; - var x; - var y; - var s; - - x = scalar2ndarray( 10.0, 'float64', 'row-major' ); - - // Full slice: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -2 ); - s1 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other row, starting from second-to-last row: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, null, -2 ); - s1 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 30, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 2, 0, -1 ); - s1 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports broadcasting (ndims=3)', function test( t ) { - var expected; - var actual; - var xbuf; - var ybuf; - var s0; - var s1; - var s2; - var x; - var y; - var s; - - xbuf = typedarray( [ 10.0 ], 'float64' ); - x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' ); - - // Full slice: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s = new MultiSlice( null, null, null ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ], - [ - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ], - [ 10, 10, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip every other element: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, -1 ); - s1 = new Slice( null, null, -2 ); - s2 = new Slice( null, null, -2 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ], - [ - [ 0, 0, 0 ], - [ 10, 0, 10 ], - [ 0, 0, 0 ], - [ 10, 0, 10 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Reverse order and skip elements, starting from specified elements: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( null, null, 1 ); - s1 = new Slice( 2, null, -2 ); - s2 = new Slice( 1, null, -1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 10, 10, 0 ], - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Set a sub-array: - ybuf = azeros( 100, x.dtype ); - y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' ); - - s0 = new Slice( 0, 1, 1 ); - s1 = new Slice( 2, 0, -1 ); - s2 = new Slice( 0, 2, 1 ); - s = new MultiSlice( s0, s1, s2 ); - actual = sliceAssign( x, y, s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, y, 'returns expected value' ); - - expected = [ - [ - [ 0, 0, 0 ], - [ 10, 10, 0 ], - [ 10, 10, 0 ], - [ 0, 0, 0 ] - ], - [ - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ], - [ 0, 0, 0 ] - ] - ]; - actual = ndarray2array( actual ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float32', 'row-major' ), - scalar2ndarray( 10, 'int8', 'row-major' ), - scalar2ndarray( 10, 'uint16', 'row-major' ), - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float64' } ), - zeros( [ 2 ], { 'dtype': 'int16' } ), - zeros( [ 2 ], { 'dtype': 'uint32' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ), - zeros( [ 2 ], { 'dtype': 'complex128' } ) - ]; - expected = [ - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10 ], - [ 10, 10, 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -}); - -tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) { - var expected; - var values; - var actual; - var x; - var s; - var v; - var e; - var i; - var j; - - s = new MultiSlice( null ); - - x = [ - scalar2ndarray( 10, 'float64', 'row-major' ), - scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) - ]; - values = [ - zeros( [ 2 ], { 'dtype': 'float32' } ), - zeros( [ 2 ], { 'dtype': 'complex64' } ) - ]; - expected = [ - [ 10, 10 ], - [ 3, 5, 3, 5 ] - ]; - for ( i = 0; i < expected.length; i++ ) { - actual = sliceAssign( x[ i ], values[ i ], s ); - - t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); - t.strictEqual( actual, values[ i ], 'returns expected value' ); - - v = actual.data; - e = expected[ i ]; - if ( isComplexDataType( actual.dtype ) ) { - for ( j = 0; j < v.legnth; j++ ) { - t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' ); - t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' ); - } - } else { - for ( j = 0; j < v.length; j++ ) { - t.strictEqual( v[ j ], e[ j ], 'returns expected value' ); - } - } - } - t.end(); -});