diff --git a/.github/workflows/test_published_package.yml b/.github/workflows/test_published_package.yml new file mode 100644 index 0000000..77522a1 --- /dev/null +++ b/.github/workflows/test_published_package.yml @@ -0,0 +1,105 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Workflow name: +name: test_published_package + +# Workflow triggers: +on: + # Run workflow on a weekly schedule: + schedule: + # * is a special character in YAML so you have to quote this string + - cron: '19 7 * * 3' + + # Run workflow upon completion of `publish` workflow run: + workflow_run: + workflows: ["publish"] + types: [completed] + + # Allow workflow to be manually run: + workflow_dispatch: + +# Workflow jobs: +jobs: + test-published: + # Define a display name: + name: 'Test running examples of published package' + + # Define the type of virtual host machine: + runs-on: ubuntu-latest + + # Define environment variables: + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + # Run workflow job if `publish` workflow run is successful or when the workflow is manually run: + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + + # Define the job's steps: + steps: + # Checkout the repository: + - name: 'Checkout repository' + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + # Install Node.js: + - name: 'Install Node.js' + uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + with: + node-version: 20 + timeout-minutes: 5 + + # Create test directory and run examples: + - name: 'Create test directory and run examples' + run: | + cd .. + mkdir test-published + cd test-published + + # Copy example file: + cp $GITHUB_WORKSPACE/examples/index.js . + + # Create a minimal package.json + echo '{ + "name": "test-published", + "version": "1.0.0", + "main": "index.js", + "dependencies": {} + }' > package.json + + # Get package name and modify example file: + PACKAGE_NAME=$(jq -r '.name' $GITHUB_WORKSPACE/package.json) + ESCAPED_PACKAGE_NAME=$(echo "$PACKAGE_NAME" | sed 's/[\/&]/\\&/g') + + sed -i "s/require( '.\/..\/lib' )/require( '$ESCAPED_PACKAGE_NAME' )/g" index.js + + # Extract and install dependencies: + DEPS=$(grep -oP "require\(\s*'([^']+)'\s*\)" index.js | sed "s/require(\s*'//" | sed "s/'\s*)//" | grep -v "^\.") + for dep in $DEPS; do + npm install $dep --save + done + + # Run the example: + node index.js + + # Send Slack notification if job fails: + - name: 'Send notification to Slack in case of failure' + uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 + with: + status: ${{ job.status }} + channel: '#npm-ci' + if: failure() diff --git a/CHANGELOG.md b/CHANGELOG.md index b64be82..53bbdc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,46 @@
-## Unreleased (2024-11-15) +## Unreleased (2024-11-20)
### Packages +
+ +#### [@stdlib/strided/base](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/strided/base) + +
+ +
+ +##### Features + +- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec) - update namespace TypeScript declarations [(#3190)](https://github.com/stdlib-js/stdlib/pull/3190) + +
+ + + +
+ +##### BREAKING CHANGES + +- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec): update namespace declarations + + - To migrate, users should consult the corresponding packages containing the respective implementations to determine what is breaking. The primary breakages come from the `blas/*` namespace, where we recently refactored how top-level BLAS APIs operate on input arguments. + +
+ + + +
+ +
+ + +
#### [@stdlib/strided/base/strided2object](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/strided/base/strided2object) @@ -36,14 +70,27 @@ +
+ +### BREAKING CHANGES + +- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec): update namespace declarations + + - To migrate, users should consult the corresponding packages containing the respective implementations to determine what is breaking. The primary breakages come from the `blas/*` namespace, where we recently refactored how top-level BLAS APIs operate on input arguments. + +
+ + +
### Contributors -A total of 2 people contributed to this release. Thank you to the following contributors: +A total of 3 people contributed to this release. Thank you to the following contributors: - Aman Bhansali - Athan Reines +- Philipp Burckhardt
@@ -55,6 +102,7 @@ A total of 2 people contributed to this release. Thank you to the following cont
+- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec) - **feat:** update namespace TypeScript declarations [(#3190)](https://github.com/stdlib-js/stdlib/pull/3190) _(by stdlib-bot, Philipp Burckhardt)_ - [`c442b93`](https://github.com/stdlib-js/stdlib/commit/c442b93d2ed3af2a2f50402b4b0dc87e9090f596) - **feat:** add `blas/base/drotm-wasm` [(#3021)](https://github.com/stdlib-js/stdlib/pull/3021) _(by Aman Bhansali, Athan Reines)_
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2024aac..f09b30e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -59,6 +59,7 @@ Mohammad Kaif <98884589+Kaif987@users.noreply.github.com> Momtchil Momtchev Muhammad Haris Naresh Jagadeesan +Neeraj Pathak NightKnight Nithin Katta <88046362+nithinkatta@users.noreply.github.com> Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com> @@ -84,6 +85,7 @@ Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com> Ryan Seal Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com> SarthakPaandey <145528240+SarthakPaandey@users.noreply.github.com> +Saurabh Singh Seyyed Parsa Neshaei Shashank Shekhar Singh Shivam <11shivam00@gmail.com> diff --git a/base/docs/types/index.d.ts b/base/docs/types/index.d.ts index ff5a563..f989844 100644 --- a/base/docs/types/index.d.ts +++ b/base/docs/types/index.d.ts @@ -47,6 +47,7 @@ import nullaryAddonDispatch = require( './../../../base/nullary-addon-dispatch' import offsetView = require( './../../../base/offset-view' ); import quaternary = require( './../../../base/quaternary' ); import quinary = require( './../../../base/quinary' ); +import readDataView = require( './../../../base/read-dataview' ); import reinterpretBoolean = require( './../../../base/reinterpret-boolean' ); import reinterpretComplex = require( './../../../base/reinterpret-complex' ); import reinterpretComplex64 = require( './../../../base/reinterpret-complex64' ); @@ -56,12 +57,14 @@ import smap2 = require( './../../../base/smap2' ); import smskmap = require( './../../../base/smskmap' ); import smskmap2 = require( './../../../base/smskmap2' ); import stride2offset = require( './../../../base/stride2offset' ); +import strided2object = require( './../../../base/strided2object' ); import ternary = require( './../../../base/ternary' ); import unary = require( './../../../base/unary' ); import unaryAddonDispatch = require( './../../../base/unary-addon-dispatch' ); import unaryBy = require( './../../../base/unary-by' ); import unaryDtypeSignatures = require( './../../../base/unary-dtype-signatures' ); import unarySignatureCallbacks = require( './../../../base/unary-signature-callbacks' ); +import writeDataView = require( './../../../base/write-dataview' ); import zmap = require( './../../../base/zmap' ); /** @@ -1050,6 +1053,47 @@ interface Namespace { */ quinary: typeof quinary; + /** + * Copies elements from an input strided DataView to elements in an output strided array. + * + * @param N - number of indexed elements + * @param view - output DataView + * @param strideView - `view` stride length (in bytes) + * @param out - output array + * @param strideOut - `out` stride length + * @param littleEndian - boolean indicating whether the data is stored in little-endian format + * @returns output DataView + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var DataView = require( '@stdlib/array/dataview' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var view = new DataView( x.buffer ); + * + * var y = new Float64Array( x.length ); + * var out = ns.readDataView( x.length, view, 8, y, 1, true ); + * // e.g., returns [ 1.0, 2.0, 3.0, 4.0 ] + * + * var bool = ( out === y ); + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var DataView = require( '@stdlib/array/dataview' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var view = new DataView( x.buffer ); + * + * var y = new Float64Array( x.length ); + * var out = ns.readDataView.ndarray( x.length, view, 8, 0, y, 1, 0, true ); + * // e.g., returns [ 1.0, 2.0, 3.0, 4.0 ] + * + * var bool = ( out === y ); + * // returns true + */ + readDataView: typeof readDataView; + /** * Reinterprets a `BooleanArray` as a `Uint8Array`. * @@ -1304,6 +1348,51 @@ interface Namespace { */ stride2offset: typeof stride2offset; + /** + * Converts a strided array and associated metadata to an object likely to have the same "shape". + * + * ## Notes + * + * - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding strided array metadata to ensure that internal functions operating on strided arrays are provided consistent argument "shapes". + * + * - The returned object has the following properties: + * + * - **data**: reference to the input array. + * - **dtype**: array data type. + * - **length**: number of indexed elements. + * - **stride**: index increment. + * - **offset**: starting index. + * - **accessorProtocol**: boolean indicating whether the input array uses accessors for getting and setting elements. + * - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. + * + * @param N - number of indexed elements + * @param x - input array + * @param stride - index increment + * @param offset - index offset + * @returns object containing strided array data + * + * @example + * var x = { + * '0': 1, + * '1': 2, + * '2': 3, + * '4': 4, + * 'length': 4 + * }; + * var obj = ns.strided2object( 4, x, 1, 0 ); + * // returns {...} + * + * var bool = obj.accessorProtocol; + * // returns false + * + * var fcns = obj.accessors; + * // returns [ , ] + * + * var v = fcns[ 0 ]( x.data, 2 ); + * // returns 3 + */ + strided2object: typeof strided2object; + /** * Applies a ternary callback to strided input array elements and assigns results to elements in a strided output array. * @@ -1558,6 +1647,55 @@ interface Namespace { */ unarySignatureCallbacks: typeof unarySignatureCallbacks; + /** + * Copies elements from an input strided array to elements in a strided DataView. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - `x` stride length + * @param view - output DataView + * @param strideView - `view` stride length (in bytes) + * @param littleEndian - boolean indicating whether to store the data in little-endian format + * @returns output DataView + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var DataView = require( '@stdlib/array/dataview' ); + * + * var x = [ 1.0, 2.0, 3.0, 4.0 ]; + * + * var buf = new ArrayBuffer( 32 ); + * var view = new DataView( buf ); + * + * var out = ns.writeDataView( 4, x, 1, view, 8, true ); + * // returns + * + * var bool = ( out === view ); + * // returns true + * + * var v = view.getFloat64( 0, true ); + * // returns 1.0 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var DataView = require( '@stdlib/array/dataview' ); + * + * var x = [ 1.0, 2.0, 3.0, 4.0 ]; + * + * var buf = new ArrayBuffer( 32 ); + * var view = new DataView( buf ); + * + * var out = ns.writeDataView.ndarray( 4, x, 1, 0, view, 8, 0, true ); + * // returns + * + * var bool = ( out === view ); + * // returns true + * + * var v = view.getFloat64( 0, true ); + * // returns 1.0 + */ + writeDataView: typeof writeDataView; + /** * Applies a unary function to a double-precision complex floating-point strided input array and assigns results to a double-precision complex floating-point strided output array. *