From 96e1ab81f672a9f2b3fe2a6966ffcde5d3e805db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 27 Jun 2021 23:55:29 +0000 Subject: [PATCH] Auto-generated commit --- .github/workflows/benchmark.yml | 21 ++ .github/workflows/cancel.yml | 26 +- .github/workflows/close_pull_requests.yml | 21 ++ .github/workflows/examples.yml | 21 ++ .github/workflows/publish.yml | 35 +++ .github/workflows/test.yml | 35 ++- .github/workflows/test_coverage.yml | 43 +++- .github/workflows/test_install.yml | 28 ++- Makefile | 18 +- README.md | 9 +- base/broadcast-array/README.md | 141 +++++++++++ base/broadcast-array/docs/repl.txt | 62 +++++ base/broadcast-array/docs/types/index.d.ts | 79 ++++++ base/broadcast-array/docs/types/test.ts | 94 ++++++++ base/broadcast-array/examples/index.js | 49 ++++ base/broadcast-array/lib/copy_array.js | 53 ++++ base/broadcast-array/lib/index.js | 68 ++++++ base/broadcast-array/lib/main.js | 136 +++++++++++ base/broadcast-array/package.json | 68 ++++++ base/broadcast-shapes/README.md | 2 +- base/broadcast-shapes/docs/repl.txt | 4 +- base/broadcast-shapes/docs/types/index.d.ts | 2 +- base/broadcast-shapes/lib/main.js | 2 +- base/docs/types/index.d.ts | 2 +- dtypes/docs/types/tsconfig.json | 39 --- dtypes/docs/types/tslint.json | 252 -------------------- package.json | 2 +- 27 files changed, 992 insertions(+), 320 deletions(-) create mode 100644 base/broadcast-array/README.md create mode 100644 base/broadcast-array/docs/repl.txt create mode 100644 base/broadcast-array/docs/types/index.d.ts create mode 100644 base/broadcast-array/docs/types/test.ts create mode 100644 base/broadcast-array/examples/index.js create mode 100644 base/broadcast-array/lib/copy_array.js create mode 100644 base/broadcast-array/lib/index.js create mode 100644 base/broadcast-array/lib/main.js create mode 100644 base/broadcast-array/package.json delete mode 100644 dtypes/docs/types/tsconfig.json delete mode 100644 dtypes/docs/types/tslint.json diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e51e34ea..dda052a5 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,8 +1,29 @@ +#/ +# @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: workflow_dispatch: +# Workflow jobs: jobs: benchmark: runs-on: ubuntu-latest diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml index 0b341b65..11e08932 100644 --- a/.github/workflows/cancel.yml +++ b/.github/workflows/cancel.yml @@ -1,7 +1,29 @@ -name: Cancel Previous Runs +#/ +# @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. +#/ -on: push +# Workflow name: +name: Cancel Workflow Runs +# Workflow triggers: +on: + workflow_dispatch: + +# Workflow jobs: jobs: cancel: runs-on: ubuntu-latest diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml index 0542842a..87a964a3 100644 --- a/.github/workflows/close_pull_requests.yml +++ b/.github/workflows/close_pull_requests.yml @@ -1,9 +1,30 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2021 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Workflow name: name: Close Pull Requests +# Workflow triggers: on: pull_request_target: types: [opened] +# Workflow jobs: jobs: run: runs-on: ubuntu-latest diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 0c19f10d..6d226cbd 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -1,8 +1,29 @@ +#/ +# @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: workflow_dispatch: +# Workflow jobs: jobs: examples: runs-on: ubuntu-latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae05f51e..ac43d572 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,28 @@ +#/ +# @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: Publish Package +# Workflow triggers: on: push +# Workflow jobs: jobs: publish: runs-on: ubuntu-latest @@ -32,3 +53,17 @@ jobs: steps: ${{ toJson(steps) }} channel: '#npm-ci' if: failure() + cancel: + runs-on: ubuntu-latest + timeout-minutes: 3 + steps: + - uses: styfle/cancel-workflow-action@0.9.0 + with: + workflow_id: >- + benchmark.yml, + examples.yml, + test.yml, + test_coverage.yml, + test_install.yml, + publish.yml + access_token: ${{ github.token }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c991081..b24f0dd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,29 @@ +#/ +# @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: build +# Workflow triggers: on: workflow_dispatch: +# Workflow jobs: jobs: test: runs-on: ubuntu-latest @@ -15,12 +36,18 @@ jobs: node-version: 15 - name: Install production and development dependencies id: install - run: | - npm install + uses: nick-invision/retry@v2 + with: + timeout_minutes: 2 + max_attempts: 3 + command: npm install - name: Run tests id: tests - run: | - npm test + uses: nick-invision/retry@v2 + with: + timeout_minutes: 3 + max_attempts: 2 + command: npm test - uses: act10ns/slack@v1 with: status: ${{ job.status }} diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml index 0e8045d7..0699d785 100644 --- a/.github/workflows/test_coverage.yml +++ b/.github/workflows/test_coverage.yml @@ -1,8 +1,29 @@ +#/ +# @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: coverage +# Workflow triggers: on: workflow_dispatch: +# Workflow jobs: jobs: test: runs-on: ubuntu-latest @@ -12,13 +33,27 @@ jobs: with: node-version: 15 - name: Install production and development dependencies - run: | - npm install + uses: nick-invision/retry@v2 + with: + timeout_minutes: 2 + max_attempts: 3 + command: npm install - name: Calculate test coverage - run: | - npm run test-cov + uses: nick-invision/retry@v2 + with: + timeout_minutes: 3 + max_attempts: 2 + command: npm run test-cov - name: Upload coverage to Codecov + id: upload uses: codecov/codecov-action@v1 with: directory: reports/coverage flags: unittests + fail_ci_if_error: true + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#npm-ci' + if: failure() diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index ee70831f..e79722e3 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -1,10 +1,31 @@ +#/ +# @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: Test Installing Dependencies +# Workflow triggers: on: workflow_run: workflows: ["Publish Package"] types: [completed] +# Workflow jobs: jobs: on-success: runs-on: ubuntu-latest @@ -17,8 +38,11 @@ jobs: with: node-version: 15 - name: Install production dependencies via npm - run: | - npm install --only=prod + uses: nick-invision/retry@v2 + with: + timeout_minutes: 2 + max_attempts: 3 + command: npm install --only=prod - uses: act10ns/slack@v1 with: status: ${{ job.status }} diff --git a/Makefile b/Makefile index 6b4a6282..f73f7ee2 100644 --- a/Makefile +++ b/Makefile @@ -280,21 +280,21 @@ endif # Common exclude flags that most recipes for finding package files should use (Note: order does matter to some degree): FIND_COMMON_EXCLUDE_FLAGS ?= \ - -not -path "$(ROOT_DIR)/.*" \ - -not -path "$(NODE_MODULES)/*" \ - -not -path "$(BUILD_DIR)/*" \ - -not -path "$(REPORTS_DIR)/*" \ + '!' -path "$(ROOT_DIR)/.*" \ + '!' -path "$(NODE_MODULES)/*" \ + '!' -path "$(BUILD_DIR)/*" \ + '!' -path "$(REPORTS_DIR)/*" \ # Define exclusion flags to use when searching for benchmark files: FIND_BENCHMARKS_EXCLUDE_FLAGS ?= \ $(FIND_COMMON_EXCLUDE_FLAGS) \ - -not -path "$(ROOT_DIR)/**/$(BENCHMARKS_FIXTURES_FOLDER)/*" + '!' -path "$(ROOT_DIR)/**/$(BENCHMARKS_FIXTURES_FOLDER)/*" # Define flags for finding benchmark files: FIND_BENCHMARKS_FLAGS ?= \ -type f \ -name "$(BENCHMARKS_PATTERN)" \ - -path "$(ROOT_DIR)/**$(BENCHMARKS_FOLDER)/**" \ + \( -path "$(ROOT_DIR)/$(BENCHMARKS_FOLDER)/**" -o -path "$(ROOT_DIR)/**/$(BENCHMARKS_FOLDER)/**" \) \ -regex "$(BENCHMARKS_FILTER)" \ $(FIND_BENCHMARKS_EXCLUDE_FLAGS) @@ -308,13 +308,13 @@ FIND_BENCHMARKS_CMD ?= find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_BENCHMARKS_ # Define exclusion flags to use when searching for examples files: FIND_EXAMPLES_EXCLUDE_FLAGS ?= \ $(FIND_COMMON_EXCLUDE_FLAGS) \ - -not -path "$(ROOT_DIR)/**/$(EXAMPLES_FIXTURES_FOLDER)/*" + '!' -path "$(ROOT_DIR)/**/$(EXAMPLES_FIXTURES_FOLDER)/*" # Define flags for finding examples files: FIND_EXAMPLES_FLAGS ?= \ -type f \ -name "$(EXAMPLES_PATTERN)" \ - -path "$(ROOT_DIR)/**$(EXAMPLES_FOLDER)/**" \ + \( -path "$(ROOT_DIR)/$(EXAMPLES_FOLDER)/**" -o -path "$(ROOT_DIR)/**/$(EXAMPLES_FOLDER)/**" \) \ -regex "$(EXAMPLES_FILTER)" \ $(FIND_EXAMPLES_EXCLUDE_FLAGS) @@ -328,7 +328,7 @@ FIND_EXAMPLES_CMD ?= find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_EXAMPLES_FLAG # Define exclusion flags to use when searching for test files: FIND_TESTS_EXCLUDE_FLAGS ?= \ $(FIND_COMMON_EXCLUDE_FLAGS) \ - -not -path "$(ROOT_DIR)/**/$(TESTS_FIXTURES_FOLDER)/*" + '!' -path "$(ROOT_DIR)/**/$(TESTS_FIXTURES_FOLDER)/*" # Define flags for finding test files: FIND_TESTS_FLAGS ?= \ diff --git a/README.md b/README.md index 63fd1094..0bad4aeb 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and 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]. +#### Community + +[![Chat][chat-image]][chat-url] + --- ## License @@ -160,9 +164,12 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors]. [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray/main.svg [coverage-url]: https://codecov.io/github/stdlib-js/ndarray?branch=main -[dependencies-image]: https://img.shields.io/david/stdlib-js/ndarray +[dependencies-image]: https://img.shields.io/david/stdlib-js/ndarray.svg [dependencies-url]: https://david-dm.org/stdlib-js/ndarray/main +[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg +[chat-url]: https://gitter.im/stdlib-js/stdlib/ + [stdlib]: https://github.com/stdlib-js/stdlib [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors diff --git a/base/broadcast-array/README.md b/base/broadcast-array/README.md new file mode 100644 index 00000000..5843d2e6 --- /dev/null +++ b/base/broadcast-array/README.md @@ -0,0 +1,141 @@ + + +# broadcastArray + +> Broadcast an [ndarray][@stdlib/ndarray/base/ctor] to a specified shape. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var broadcastArray = require( '@stdlib/ndarray/base/broadcast-array' ); +``` + +#### broadcastArray( arr, shape ) + +Broadcasts an [ndarray][@stdlib/ndarray/base/ctor] to a specified `shape`. + +```javascript +var array = require( '@stdlib/ndarray/array' ); + +// Create a 2x2 ndarray: +var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +// returns + +// Broadcast to a 2x2x2 ndarray: +var y = broadcastArray( x, [ 2, 2, 2 ] ); +// returns +``` + +
+ + + + + +
+ +## Notes + +- The function throws an error if a provided [ndarray][@stdlib/ndarray/base/ctor] is [incompatible][@stdlib/ndarray/base/broadcast-shapes] with a provided shape. +- The returned [ndarray][@stdlib/ndarray/base/ctor] is a view on the input [ndarray][@stdlib/ndarray/base/ctor] data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned [ndarray][@stdlib/ndarray/base/ctor], copy the [ndarray][@stdlib/ndarray/base/ctor] **before** performing operations which may mutate elements. +- The returned [ndarray][@stdlib/ndarray/base/ctor] is a "base" [ndarray][@stdlib/ndarray/base/ctor], and, thus, the returned [ndarray][@stdlib/ndarray/base/ctor] does not perform bounds checking or afford any of the guarantees of the non-base [ndarray][@stdlib/ndarray/ctor] constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. + +
+ + + + + +
+ +## Examples + + + +```javascript +var array = require( '@stdlib/ndarray/array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var ind2sub = require( '@stdlib/ndarray/ind2sub' ); +var broadcastArray = require( '@stdlib/ndarray/base/broadcast-array' ); + +// Create a 2x2 array: +var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +// returns + +// Broadcast the array to 3x2x2: +var y = broadcastArray( x, [ 3, 2, 2 ] ); +// returns + +// Retrieve the shape: +var sh = y.shape; +// returns [ 3, 2, 2 ] + +// Retrieve the number of elements: +var N = numel( sh ); + +// Loop through the array elements... +var sub; +var v; +var i; +for ( i = 0; i < N; i++ ) { + v = y.iget( i ); + sub = ind2sub( sh, i ); + console.log( 'Y[%s] = %d', sub.join( ', ' ), v ); +} +``` + +
+ + + + + +
+ +
+ + + + + + + + diff --git a/base/broadcast-array/docs/repl.txt b/base/broadcast-array/docs/repl.txt new file mode 100644 index 00000000..23077412 --- /dev/null +++ b/base/broadcast-array/docs/repl.txt @@ -0,0 +1,62 @@ + +{{alias}}( arr, shape ) + Broadcasts an ndarray to a specified shape. + + The returned array is a view on the input array data buffer. The view is + typically **not** contiguous. As more than one element of a returned view + may refer to the same memory location, writing to the view may affect + multiple elements. If you need to write to the returned array, copy the + array before performing operations which may mutate elements. + + The returned array is a "base" ndarray, and, thus, the returned array does + not perform bounds checking or afford any of the guarantees of the non-base + ndarray constructor. The primary intent of this function is to broadcast an + ndarray-like object within internal implementations and to do so with + minimal overhead. + + The function throws an error if a provided ndarray is incompatible with a + provided shape. + + Parameters + ---------- + arr: ndarray + Input array. + + shape: ArrayLikeObject + Desired shape. + + Returns + ------- + out: ndarray + Broadcasted array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) + + > var sh = x.shape + [ 2, 2 ] + > var y = {{alias}}( x, [ 3, 2, 2 ] ) + + > sh = y.shape + [ 3, 2, 2 ] + > var v = y.get( 0, 0, 0 ) + 1 + > v = y.get( 0, 0, 1 ) + 2 + > v = y.get( 0, 1, 0 ) + 3 + > v = y.get( 0, 1, 1 ) + 4 + > v = y.get( 1, 0, 0 ) + 1 + > v = y.get( 1, 1, 0 ) + 3 + > v = y.get( 2, 0, 0 ) + 1 + > v = y.get( 2, 1, 1 ) + 4 + + See Also + -------- + diff --git a/base/broadcast-array/docs/types/index.d.ts b/base/broadcast-array/docs/types/index.d.ts new file mode 100644 index 00000000..86b32dd1 --- /dev/null +++ b/base/broadcast-array/docs/types/index.d.ts @@ -0,0 +1,79 @@ +/* +* @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. +*/ + +// TypeScript Version: 2.0 + +/// + +import { ArrayLike } from '@stdlib/types/array'; +import { ndarray } from '@stdlib/types/ndarray'; + +/** +* Broadcasts an ndarray to a specified shape. +* +* ## Notes +* +* - The function throws an error if a provided ndarray is incompatible with a provided shape. +* - The returned array is a view on the input array data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements. +* - The returned array is a "base" ndarray, and, thus, the returned array does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. +* +* @param arr - input array +* @param shape - desired shape +* @throws input array cannot have more dimensions than the desired shape +* @throws input array dimension sizes must be `1` or equal to the corresponding dimension in the provided shape +* @returns broadcasted array +* +* @example +* var array = require( `@stdlib/ndarray/array` ); +* +* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +* // returns +* +* var shx = x.shape; +* // returns [ 2, 2 ] +* +* var y = broadcastArray( x, [ 3, 2, 2 ] ); +* // returns +* +* var shy = y.shape; +* // returns [ 3, 2, 2 ] +* +* var v = y.get( 0, 0, 0 ); +* // returns 1 +* +* v = y.get( 0, 0, 1 ); +* // returns 2 +* +* v = y.get( 1, 0, 0 ); +* // returns 1 +* +* v = y.get( 1, 1, 0 ); +* // returns 3 +* +* v = y.get( 2, 0, 0 ); +* // returns 1 +* +* v = y.get( 2, 1, 1 ); +* // returns 4 +*/ +declare function broadcastArray( arr: ndarray, shape: ArrayLike ): ndarray; // tslint:disable-line:max-line-length + + +// EXPORTS // + +export = broadcastArray; diff --git a/base/broadcast-array/docs/types/test.ts b/base/broadcast-array/docs/types/test.ts new file mode 100644 index 00000000..d25736a7 --- /dev/null +++ b/base/broadcast-array/docs/types/test.ts @@ -0,0 +1,94 @@ +/* +* @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. +*/ + +/// + +import { ndarray } from '@stdlib/types/ndarray'; +import broadcastArray = require( './index' ); + +/** +* Mock function to create an ndarray-like object. +* +* @return ndarray-like object +*/ +function array(): ndarray { + const obj: ndarray = { + 'byteLength': 80, + 'BYTES_PER_ELEMENT': 8, + 'data': new Float64Array( 10 ), + 'dtype': 'float64', + 'flags': { + 'ROW_MAJOR_CONTIGUOUS': true, + 'COLUMN_MAJOR_CONTIGUOUS': false + }, + 'length': 10, + 'ndims': 1, + 'offset': 0, + 'order': 'row-major', + 'shape': [ 10 ], + 'strides': [ 1 ], + 'get': (): number => 0, + 'set': (): ndarray => obj + }; + return obj; +} + + +// TESTS // + +// The function returns an ndarray... +{ + const x = array(); + + broadcastArray( x, [ 2, 2, 2 ] ); // $ExpectType ndarray +} + +// The compiler throws an error if the function is not provided a first argument which is an ndarray... +{ + broadcastArray( '5', [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( 5, [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( true, [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( false, [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( null, [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( {}, [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError + broadcastArray( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError +} + +// The compiler throws an error if the function is not provided a second argument which is an array-like object containing array-like objects containing numbers... +{ + const x = array(); + + broadcastArray( x, '5' ); // $ExpectError + broadcastArray( x, 5 ); // $ExpectError + broadcastArray( x, true ); // $ExpectError + broadcastArray( x, false ); // $ExpectError + broadcastArray( x, null ); // $ExpectError + broadcastArray( x, {} ); // $ExpectError + broadcastArray( x, [ '5' ] ); // $ExpectError + broadcastArray( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = array(); + + broadcastArray(); // $ExpectError + broadcastArray( x ); // $ExpectError + broadcastArray( x, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError +} diff --git a/base/broadcast-array/examples/index.js b/base/broadcast-array/examples/index.js new file mode 100644 index 00000000..4d803650 --- /dev/null +++ b/base/broadcast-array/examples/index.js @@ -0,0 +1,49 @@ +/** +* @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. +*/ + +'use strict'; + +var array = require( './../../../array' ); +var numel = require( './../../../base/numel' ); +var ind2sub = require( './../../../ind2sub' ); +var broadcastArray = require( './../lib' ); + +// Create a 2x2 array: +var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +// returns + +// Broadcast the array to 3x2x2: +var y = broadcastArray( x, [ 3, 2, 2 ] ); +// returns + +// Retrieve the shape: +var sh = y.shape; +// returns [ 3, 2, 2 ] + +// Retrieve the number of elements: +var N = numel( sh ); + +// Loop through the array elements... +var sub; +var v; +var i; +for ( i = 0; i < N; i++ ) { + v = y.iget( i ); + sub = ind2sub( sh, i ); + console.log( 'Y[%s] = %d', sub.join( ', ' ), v ); +} diff --git a/base/broadcast-array/lib/copy_array.js b/base/broadcast-array/lib/copy_array.js new file mode 100644 index 00000000..6c9a4276 --- /dev/null +++ b/base/broadcast-array/lib/copy_array.js @@ -0,0 +1,53 @@ +/** +* @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. +*/ + +'use strict'; + +// MAIN / + +/** +* Copies an array-like object to an array. +* +* @private +* @param {ArrayLikeObject} arr - input array +* @returns {Array} output array +* +* @example +* var arr = [ 1, 2, 3 ]; +* +* var out = copyArray( arr ); +* // returns [ 1, 2, 3 ] +* +* var bool = ( out === arr ); +* // returns false +*/ +function copyArray( arr ) { + var out; + var i; + + out = []; + for ( i = 0; i < arr.length; i++ ) { + out.push( arr[ i ] ); + } + return out; +} + + +// EXPORTS // + +module.exports = copyArray; diff --git a/base/broadcast-array/lib/index.js b/base/broadcast-array/lib/index.js new file mode 100644 index 00000000..30912013 --- /dev/null +++ b/base/broadcast-array/lib/index.js @@ -0,0 +1,68 @@ +/** +* @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. +*/ + +'use strict'; + +/** +* Broadcast an ndarray to a specified shape. +* +* @module @stdlib/ndarray/base/broadcast-array +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* var broadcastArray = require( '@stdlib/ndarray/base/broadcast-array' ); +* +* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +* // returns +* +* var shx = x.shape; +* // returns [ 2, 2 ] +* +* var y = broadcastArray( x, [ 3, 2, 2 ] ); +* // returns +* +* var shy = y.shape; +* // returns [ 3, 2, 2 ] +* +* var v = y.get( 0, 0, 0 ); +* // returns 1 +* +* v = y.get( 0, 0, 1 ); +* // returns 2 +* +* v = y.get( 1, 0, 0 ); +* // returns 1 +* +* v = y.get( 1, 1, 0 ); +* // returns 3 +* +* v = y.get( 2, 0, 0 ); +* // returns 1 +* +* v = y.get( 2, 1, 1 ); +* // returns 4 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/base/broadcast-array/lib/main.js b/base/broadcast-array/lib/main.js new file mode 100644 index 00000000..55924917 --- /dev/null +++ b/base/broadcast-array/lib/main.js @@ -0,0 +1,136 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var ndarray = require( './../../../base/ctor' ); +var copy = require( './copy_array.js' ); + + +// MAIN // + +/** +* Broadcasts an ndarray to a specified shape. +* +* ## Notes +* +* - The returned array is a view on the input array data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements. +* +* @param {ndarray} arr - input array +* @param {NonNegativeIntegerArray} shape - desired shape +* @throws {Error} input array cannot have more dimensions than the desired shape +* @throws {Error} input array dimension sizes must be `1` or equal to the corresponding dimension in the provided shape +* @throws {Error} input array and desired shape must be broadcast compatible +* @returns {ndarray} broadcasted array +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +* // returns +* +* var shx = x.shape; +* // returns [ 2, 2 ] +* +* var y = broadcastArray( x, [ 3, 2, 2 ] ); +* // returns +* +* var shy = y.shape; +* // returns [ 3, 2, 2 ] +* +* var v = y.get( 0, 0, 0 ); +* // returns 1 +* +* v = y.get( 0, 0, 1 ); +* // returns 2 +* +* v = y.get( 1, 0, 0 ); +* // returns 1 +* +* v = y.get( 1, 1, 0 ); +* // returns 3 +* +* v = y.get( 2, 0, 0 ); +* // returns 1 +* +* v = y.get( 2, 1, 1 ); +* // returns 4 +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +* // returns +* +* var y = broadcastArray( x, [ 3, 2 ] ); +* // throws +*/ +function broadcastArray( arr, shape ) { + var strides; + var dim; + var sh; + var st; + var N; + var M; + var d; + var i; + var j; + + N = shape.length; + sh = arr.shape; + M = sh.length; + if ( N < M ) { + throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' ); + } + // Initialize a strides array... + strides = []; + for ( i = 0; i < N; i++ ) { + strides.push( 0 ); + } + // Determine the output array strides... + st = arr.strides; + for ( i = N-1; i >= 0; i-- ) { + j = M - N + i; + if ( j < 0 ) { + // Prepended singleton dimension; stride is zero... + continue; + } + d = sh[ j ]; + dim = shape[ i ]; + if ( dim !== 0 && dim < d ) { + throw new Error( 'invalid argument. Input array cannot be broadcast to the specified shape, as the specified shape has a dimension whose size is less than the size of the corresponding dimension in the input array. Array shape: ('+copy( sh ).join( ', ' )+'). Desired shape: ('+copy( shape ).join( ', ' )+'). Dimension: '+i+'.' ); + } + if ( d === dim ) { + strides[ i ] = st[ j ]; + } else if ( d === 1 ) { + // In order to broadcast dimensions, we set the stride for that dimension to zero... + strides[ i ] = 0; + } else { + // At this point, we know that `dim > d` and that `d` does not equal `1` (e.g., `dim=3` and `d=2`); in which case, the shapes are considered incompatible (even for desired shapes which are multiples of array dimensions, as might be desired when "tiling" an array; e.g., `dim=4` and `d=2`)... + throw new Error( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: ('+copy( sh ).join( ', ' )+'). Desired shape: ('+copy( shape ).join( ', ' )+'). Dimension: '+i+'.' ); + } + } + return ndarray( arr.dtype, arr.data, copy( shape ), strides, arr.offset, arr.order ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = broadcastArray; diff --git a/base/broadcast-array/package.json b/base/broadcast-array/package.json new file mode 100644 index 00000000..86d87e23 --- /dev/null +++ b/base/broadcast-array/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/ndarray/base/broadcast-array", + "version": "0.0.0", + "description": "Broadcast an ndarray to a specified shape.", + "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": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "ndarray", + "broadcast", + "broadcasting", + "reshape", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/base/broadcast-shapes/README.md b/base/broadcast-shapes/README.md index 2889701b..ee836226 100644 --- a/base/broadcast-shapes/README.md +++ b/base/broadcast-shapes/README.md @@ -174,7 +174,7 @@ var sh = broadcastShapes( [ sh1, sh2 ] ); Accordingly, dimensions of size `0` must be paired with a dimension of size `0` or `1`. In such cases, by the rules above, the size of the corresponding output shape dimension is `0`. -- The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast one another). +- The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast with one another). ```javascript var sh1 = [ 3, 2 ]; diff --git a/base/broadcast-shapes/docs/repl.txt b/base/broadcast-shapes/docs/repl.txt index 30a81c49..f1d92f69 100644 --- a/base/broadcast-shapes/docs/repl.txt +++ b/base/broadcast-shapes/docs/repl.txt @@ -8,7 +8,7 @@ 2. one dimension is `1`. The function returns `null` if provided incompatible shapes (i.e., shapes - which cannot be broadcast one another). + which cannot be broadcast with one another). Parameters ---------- @@ -17,7 +17,7 @@ Returns ------- - out: Array + out: Array|null Broadcast shape. Examples diff --git a/base/broadcast-shapes/docs/types/index.d.ts b/base/broadcast-shapes/docs/types/index.d.ts index ae9ee0fa..f46767db 100644 --- a/base/broadcast-shapes/docs/types/index.d.ts +++ b/base/broadcast-shapes/docs/types/index.d.ts @@ -32,7 +32,7 @@ import { ArrayLike } from '@stdlib/types/array'; * 1. the dimensions are equal. * 2. one dimension is `1`. * -* - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast one another). +* - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast with one another). * * @param shapes - array shapes * @returns broadcast shape diff --git a/base/broadcast-shapes/lib/main.js b/base/broadcast-shapes/lib/main.js index 5529ebbe..8558e608 100644 --- a/base/broadcast-shapes/lib/main.js +++ b/base/broadcast-shapes/lib/main.js @@ -30,7 +30,7 @@ * 1. the dimensions are equal. * 2. one dimension is `1`. * -* - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast one another). +* - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast with one another). * * @param {Array} shapes - array of shape arrays * @returns {(NonNegativeIntegerArray|null)} broadcast shape (or `null`) diff --git a/base/docs/types/index.d.ts b/base/docs/types/index.d.ts index cee1600e..d3922fb0 100644 --- a/base/docs/types/index.d.ts +++ b/base/docs/types/index.d.ts @@ -94,7 +94,7 @@ interface Namespace { * 1. the dimensions are equal. * 2. one dimension is `1`. * - * - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast one another). + * - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast with one another). * * @param shapes - array shapes * @returns broadcast shape diff --git a/dtypes/docs/types/tsconfig.json b/dtypes/docs/types/tsconfig.json deleted file mode 100644 index a541d610..00000000 --- a/dtypes/docs/types/tsconfig.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "compilerOptions": { - "allowSyntheticDefaultImports": false, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "alwaysStrict": true, - "baseUrl": ".", - "charset": "utf8", - "forceConsistentCasingInFileNames": true, - "keyofStringsOnly": false, - "lib": [ - "es6" - ], - "locale": "en", - "module": "commonjs", - "moduleResolution": "node", - "newLine": "lf", - "noEmit": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": false, - "noImplicitThis": true, - "noStrictGenericChecks": false, - "noUnusedLocals": true, - "noUnusedParameters": true, - "paths": {}, - "pretty": true, - "strictBindCallApply": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "suppressExcessPropertyErrors": false, - "suppressImplicitAnyIndexErrors": false, - "typeRoots": [ "." ], - "types": [] - }, - "exclude": [ - "node_modules" - ] -} diff --git a/dtypes/docs/types/tslint.json b/dtypes/docs/types/tslint.json deleted file mode 100644 index a0c360d8..00000000 --- a/dtypes/docs/types/tslint.json +++ /dev/null @@ -1,252 +0,0 @@ -{ - "extends": "dtslint/dtslint.json", - "rules": { - "expect": true, - "export-just-namespace": true, - "no-any-union": true, - "no-bad-reference": true, - "no-const-enum": true, - "no-dead-reference": true, - "no-declare-current-package": true, - "no-import-default-of-export-equals": true, - "no-outside-dependencies": true, - "no-padding": true, - "no-redundant-undefined": true, - "no-relative-import-in-test": false, - "no-self-import": true, - "no-single-declare-module": true, - "no-single-element-tuple-type": true, - "no-unnecessary-generics": true, - "no-useless-files": true, - "prefer-declare-function": true, - "strict-export-declare-modifiers": true, - "trim-file": true, - "unified-signatures": true, - "void-return": true, - - "adjacent-overload-signatures": true, - "ban-ts-ignore": false, - "ban-types": false, - "member-access": [ true, "no-public" ], - "member-ordering": [ true, "fields-first" ], - "no-any": false, - "no-empty-interface": true, - "no-import-side-effect": true, - "no-inferrable-types": true, - "no-internal-module": true, - "no-magic-numbers": false, - "no-namespace": true, - "no-non-null-assertion": true, - "no-parameter-reassignment": false, - "no-reference": true, - "no-unnecessary-type-assertion": true, - "no-var-requires": true, - "only-arrow-functions": false, - "prefer-for-of": false, - "promise-function-async": false, - "typedef": true, - "typedef-whitespace": [ true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - } - ], - "unified-signatures": true, - - "await-promise": true, - "ban-comma-operator": true, - "ban": [ true, - { - "name": [ "*", "forEach" ], - "message": "Use a regular `for` loop instead." - } - ], - "curly": true, - "forin": true, - "function-constructor": true, - "import-blacklist": [ true, "lodash" ], - "label-position": true, - "no-arg": true, - "no-bitwise": false, - "no-conditional-assignment": true, - "no-console": true, - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-duplicate-switch-case": true, - "no-duplicate-variable": [ true, "check-parameters" ], - "no-dynamic-delete": false, - "no-empty": true, - "no-eval": true, - "no-floating-promises": true, - "no-for-in-array": true, - "no-implicit-dependencies": false, - "no-inferred-empty-object-type": true, - "no-invalid-template-strings": true, - "no-invalid-this": true, - "no-misused-new": true, - "no-null-keyword": false, - "no-object-literal-type-assertion": true, - "no-return-await": true, - "no-shadowed-variable": false, - "no-sparse-arrays": true, - "no-string-literal": false, - "no-string-throw": true, - "no-submodule-imports": false, - "no-switch-case-fall-through": true, - "no-this-assignment": [ true, - { - "allowed-names": [ "^self$" ], - "allow-destructuring": true - } - ], - "no-unbound-method": [ true, "ignore-static" ], - "no-unnecessary-class": true, - "no-unsafe-any": true, - "no-unsafe-finally": true, - "no-unused-expression": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "no-void-expression": true, - "prefer-conditional-expression": false, - "prefer-object-spread": false, - "radix": true, - "restrict-plus-operands": true, - "strict-boolean-expressions": false, - "strict-type-predicates": true, - "switch-default": true, - "triple-equals": true, - "unnecessary-constructor": true, - "use-default-type-parameter": true, - "use-isnan": true, - - "cyclomatic-complexity": false, - "deprecation": true, - "eofline": true, - "indent": [ true, "tabs", 4 ], - "linebreak-style": [ true, "LF" ], - "max-classes-per-file": [ true, 1 ], - "max-file-line-count": [ true, 1000 ], - "max-line-length": [ true, - { - "limit": 80, - "ignore-pattern": "^import |\\/\\/ |\\/?\\* " - } - ], - "no-default-export": false, - "no-default-import": false, - "no-duplicate-imports": true, - "no-mergeable-namespace": true, - "no-require-imports": false, - "object-literal-sort-keys": false, - "prefer-const": true, - "prefer-readonly": true, - "trailing-comma": [ false, - { - "esSpecCompliant": true - } - ], - - "align": false, - "array-type": [ true, "generic" ], - "arrow-parens": true, - "arrow-return-shorthand": true, - "binary-expression-operand-order": true, - "callable-types": true, - "class-name": true, - "comment-format": [ true, "check-space" ], - "comment-type": false, - "completed-docs": true, - "encoding": true, - "file-header": false, - "file-name-casing": [ true, "snake-case" ], - "import-spacing": true, - "increment-decrement": true, - "interface-name": [ true, "never-prefix" ], - "interface-over-type-literal": true, - "jsdoc-format": false, - "match-default-export-name": false, - "newline-before-return": false, - "newline-per-chained-call": false, - "new-parens": true, - "no-angle-bracket-type-assertion": true, - "no-boolean-literal-compare": false, - "no-consecutive-blank-lines": [ true, 2 ], - "no-irregular-whitespace": true, - "no-parameter-properties": true, - "no-redundant-jsdoc": true, - "no-reference-import": true, - "no-trailing-whitespace": true, - "no-unnecessary-callback-wrapper": true, - "no-unnecessary-initializer": true, - "no-unnecessary-qualifier": true, - "number-literal-format": false, - "object-literal-key-quotes": [ true, "always" ], - "object-literal-shorthand": [ true, "never" ], - "one-line": [ true, - "check-catch", - "check-finally", - "check-else", - "check-open-brace", - "check-whitespace" - ], - "one-variable-per-declaration": true, - "ordered-imports": [ true, - { - "grouped-imports": false, - "import-sources-order": "any", - "named-imports-order": "any", - "module-source-path": "full" - } - ], - "prefer-function-over-method": [ true, "allow-public", "allow-protected" ], - "prefer-method-signature": true, - "prefer-switch": [ true, - { - "min-cases": 5 - } - ], - "prefer-template": false, - "prefer-while": true, - "quotemark": [ true, "single", "avoid-escape", "avoid-template" ], - "return-undefined": false, - "semicolon": [ true, "always" ], - "space-before-function-paren": [ true, - { - "anonymous": "always", - "named": "never", - "asyncArrow": "always", - "method": "never", - "constructor": "never" - } - ], - "space-within-parens": [ true, 1 ], - "switch-final-break": [ true, "always" ], - "type-literal-delimiter": [ true, - { - "singleLine": "always" - } - ], - "unnecessary-bind": true, - "variable-name": [ true, "ban-keywords", "check-format" ], - "whitespace": [ true, - "check-branch", - "check-decl", - "check-operator", - "check-rest-spread", - "check-separator", - "check-type", - "check-preblock" - ] - } -} diff --git a/package.json b/package.json index a82cf096..af9e6bab 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "examples": "make examples", "benchmark": "make benchmark" }, - "homepage": "https://github.com/stdlib-js/stdlib", + "homepage": "https://stdlib.io", "repository": { "type": "git", "url": "git://github.com/stdlib-js/ndarray.git"